I need to do complex numbers operation. After I defined a variable, named 'squareRoot', using "complex.h" stadard library, however, Visual Studio 2022 told me identifier 'squareRoot' is undefined. It made me comfused! What's wrong with my code? enter image description here
I just want to know how to define a complex variable, even though I have referenced some similar codes that define that complex number.
Your code is fine as far as C is concerned, but Microsoft has always been a bit out of step with C standards. It seems that the functions from complex.h
are supported in VS2022, but you will have to use _Dcomplex
in place of double complex
. You can read more about support for complex.h
in Visual Studio 2022 here.