General Information for CGS2423

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.


Creating the header to be included in all C programs

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.

Back to Index


Program Guidelines

Each program must follow these rules.

Back to Index


Compiling, linking and running C on UNIX

These are the steps you would follow to execute a C program:

  1. In order to do this, you must first create the source file using an editor. Be sure that all your C files have an extension of .c.
  2. Assuming that your file is stored in prog.c, you then issue the command
    	gcc -o prog prog.c
    
  3. To run the program, issue the command
    	prog
    
  4. Use the cat command to have the contents of the file displayed on the screen.
    	cat prog.c
    

Back to Index


Getting a free C++ compiler

There is a free C++ compiler that can be obtained from http://gcc.gnu.org/

Back to Index


Pausing output so that results can be seen

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.

Back to Index


You are visitor number to visit this page since 10/13/00.