| Computing and Networking Using C in UNIX |
This document contains the following topics:
Example using EMACS to edit a C file:
gemacs file-name.c
cc file-name.c or gcc file-name.c
Technical Note: There are two standard C formats: ANSI and K&R. gcc compilers work with both ANSI and K&R. cc compilers usually use one or the other: ANSI or K&R. For more information type "man cc" or "man gcc" at the UNIX prompt.The compiler creates a file called a.out, which is the executable version of the C program. After compilation the program it can be run by typing:
a.out
-O Name the final executable file (if this option is not used
the file created will be called a.out)
cc -o out-file-name file-name.c
or
gcc -o out-file-name file-name.c
main()
{
float x, y, z, sum, avg;
printf("Please enter 3 numbers: ");
scanf("%f %f %f", &x, &y, &z);
sum = x + y + z;
avg = sum / 3.0;
printf("The average of the three numbers is: %f\n",avg);
}
On-line manual pages for the C compiler, C library functions, and other UNIX commands are available. Computing and Networking also maintains a current copy of UNIX manuals including C.
| NMSU Home | Directory | Search | Comments | Help |
| Computing & Networking | Library |
Phonebook |