Next 19.B: Programming Courtesy Up 19: Running C Prev 19: Running C Contents


Specialized

§ 19.A: Compiling C Programs


Once you have gone through the trouble of writing a program, you should enjoy the excitement of running it. The most common Unix C compiler is cc

Here myprog.c is the name of the file containing the C source code of the program you wish to compile.

If your program does not contain serious errors, this command produces a file a.out. If your program is complete (and not just a procedure, for example), a.out will be executable version of area.c. If your program is not complete, a.out will contain an object code version of it. To run the executable, just enter a.out

The name a.out is not terribly descriptive, so Unix gives you the option (-o) of naming your objects as you compile them:

This compiles your C program into the object it-runs. If your object is executebale, you execute it just be entering its name: