First, I do know that it is not recommended to include .c in another .c but to do it with .h instead, everyone told me that
but my instructor demands it, but whenever i try it it just won't compile.
i appretiate any help...
im working on ubunto 12.04 platform and it gives me this error in the picture attached.
so i have the main.c :
#include <stdio.h>
#include "complex.c"
void read_comp(complex,int,int);
typedef struct ComplexNumber{ /* Structure that holds a complex number*/
double x;
double y;
} complex;
int main()
{
complex A,B,C,D,E,F;
/*=========== Resets numbers to zero ===========*/
A.x = A.y = B.x = B.y = C.x = C.y = D.x = D.y = E.x = E.y = F.x = F.y = 0;
read_comp(A,5.1,6.2);
return 0;
}
and my function from other .c file named, complex.c :
void read_comp(complex compNum, int a, int b)
{
compNum.x = a;
compNum.y = b;
}
and here's the makefile i did :
myprog: main.o complex.o
gcc -g -Wall -ansi -pedantic main.o complex.o -o myprog -lm
main.o: main.c
gcc -c -Wall -ansi -pedantic main.c -o main.o -lm
complex.o: complex.c
gcc -c -Wall -ansi -pedantic complex.c -o complex.o -lm