I have the following header file:
#ifndef COMPLEX_H_INCLUDED
#define COMPLEX_H_INCLUDED
typedef struct {
double r; //real part
double i; //imag part
} complex;
complex make(double r,double i);
#endif // COMPLEX_H_INCLUDED
and .c file:
#include <stdio.h>
#include <math.h>
#include "complex.h"
complex make(double re,double im)
{
complex z;
z.r=re;
z.i=im;
return z
}
Now, when I try to create a complex in a main file, I don't seem to be able to print a complex number that I've created.
#include <stdio.h>
#include <stdlib.h>
#include "complex.h"
int main()
{
double a,b;
printf("Enter real, then imaginary part:");
scanf("%f %f",a,b);
complex z;
z=make(a,b);
printf("The number is: %f%+fi",z.r,z.i);
return 0;
}
I get an error: undefined reference to make.