Here, add()
and printStudent()
are user defined functins defined in file second.c.
We are using the functions defined in second.c in the file first.c.
For that, we use the header file new.h. It will contain declaration of add
and printStudent
, but the definition
will be in second.c.
After defining the functions in new.h we include the header file in first.c.
For all of this to work, we will need to compile first.c and second.c together. This is because during compilation, the linker will link all the functions defined in new.h with where they are originally declared.
With the gcc compiler we can use the following command
gcc first.c second.c
Another way is to first only compile and assemble second.c and then compile the output together with first.c.
gcc -c second.c -o second; gcc first.c second
There are other ways to do it, but currently this is all I know.