complex output

Started by
4 comments, last by bobwrit 16 years, 3 months ago
I'm lookng for a function in c that can print out complex numbers other than cout.
-------------------------------------------------my forum LINK: here
Advertisement
Never heard of cout being used to print out complex numbers in C.

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.
-------------------------------------------------my forum LINK: here
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"?
It says that their undefined. I'm includeing complex.h and I've looked into the file and the prototypes are in the header. I'm using dev-c++.
-------------------------------------------------my forum LINK: here

This topic is closed to new replies.

Advertisement