| COP2250 | CGS4825 | COP4226 | COP2210 | CDA4101 | UNIX | HOME |
|
||||||
C programs can be run on the minicomputers at school which run the UNIX operating system. You can also use the personal computers in the JCCL and the labs in the PC building to run C programs using MS Visual C++. This page contains basic information on how to run C programs on these systems.
In every program that you hand in, you will include the following header at the beginning of the code. To save time later, put this into a file now. Name the file HEADER.INC
/*
********************************************************************
Name: (enter your name here)
Instructor: Tim Downey
Program Description: (you will type in a description here)
Oath: I attest that this program was done entirely by me
without any outside assistance, except possibly from Tim Downey.
Signed: (sign name here)
********************************************************************
*/
The opening /* and closing */ are very important. Keep the width of this box less than 65 characters. You will include this in every program you write.
Each program must follow these rules.
These are the steps you would follow to execute a C program:
gcc -o prog prog.c
prog
cat prog.c
There is a free C++ compiler that can be obtained from http://gcc.gnu.org/
In MS Visual C++, the output screen is paused so that you can view the results. In some development environments this is not done. Here is some code to insert in your program to pause the output so that results can be viewed. You do not need to include this code if you are using MS Visual C++.
Declare an extra variable in your program:
char ch;
Before the return (0) statement, insert these statements
printf("Please hit a non-blank key and press enter ");
scanf(" %c", &ch);
Please notice that there is a space before the %c in the placeholder.