CIS 22 - Data Structures: Separate Compilation
When you code another source file which calls one of the routines in the fun.c file, that calling file must contain the line
#include fun.hNOTE:You do not include fun.c.
acc -c f1.c acc -c f2.cfrom the Unix prompt. If you are running under DOS, you can do the same from the command line, using bcc or tcc for Borland or Turbo C.
The -c option on the compilation causes the compiler to generate only an object file. Under Unix, the object files will be named f1.o and f2.o; under DOS they will be named f1.obj and f2.obj.
To compile the main program, you will use the command
acc prog.c f1.o f2.ounder Unix, and similarly using bcc or tcc and .obj under DOS. This will generate an executable file, named a.out under Unix, or prog.exe under DOS.
You can more efficiently manage projects involving separate files by using the Unix makefile utility, or by using the project facility of the DOS/Windows-based compilers.
To redirect stdin only:
a.out < inputfileTo redirect stdout only:
a.out > outputfileTo redirect both stdin and stdout:
a.out < inputfile > outputfile