/* * cpx.h - simple complex number package * version 2: struct pointer parameters & string dynamic allocation * CSE 413 demo 11/06 HP */ #ifndef CPX_H #define CPX_H typedef struct { /* complex numbers with rectangular coordinates */ double re, im; } Complex; /* return a complex number with real part = x and imaginary = y */ Complex mk_complex(double x, double y); /* return the sum of complex numbers c and d */ Complex cpx_add(Complex* c, Complex* d); /* return a representation of c as re+im i in a newly allocated string */ char* cpx2str(Complex* c); #endif