>

Compiling and Running C Programs

CS 1323 Honors, Fall 1996

To Compile a C Program

Issue the Unix command
gcc -lm -ansi -pedantic-errors programFilename.c
where programFilename is the name of the file containing your C program. (Note: -lm is hyphen lower-case-el lower-case-em.)

If the program conforms to the grammatical rules of C, this command will generate a file called a.out that contains a version of your program translated into a form that the the operating system can run. This file is known as the "executable file" for the C program. You may want to give the a.out file another name, to keep it from getting overwritten when you compile another C program:

cp a.out newName.out

To Run a Compiled C Program

Use the name of the executable file as if it were a Unix command.
For example:
a.out
runs the program generated by a compile command like
gcc -lm -ansi -pedantic-errors programFilename.c
Last Modified: