complex output
Never heard of cout being used to print out complex numbers in C.
Any way, why not this:
Any way, why not this:
printf("%d+%di",real_part,imaginary_part);
In C, you can get the real and imaginary part of a complex number via the creal() and cimag() functions for double complex numbers, crealf() and cimagf() for float complex numbers and creall() and cimagl() for long double complex numbers. They return double, float and long double values respectively, which can then be passed to printf() with the standard floating point format specifiers.
I had tried that before but somethings wrong with the functions in complex.h. I can't use any of the functions in the header, but the _Complex structure still works.
I've also tried to specify the imaginary and real parts of the variable using x.real and x.imag.
I've also tried to specify the imaginary and real parts of the variable using x.real and x.imag.
What's the problem? Do you get compiler errors? Runtime errors? Does you computer kick you in the shin while singing "The Devil Came Down to Georgia"?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement