Up Feedback Search                                                             

C
 

 

How to edit, compile and run C programs? 

bullet

Edit: Open up your favorite text editor, (gedit, emacs, or vi, refer to this quick manual question 1), create a file with .c extension. For example, I could create a simple c program like the following:  

#include <stdio.h> 

int main(){

  printf("Hello, world.\n");

  return 0;

}

Saved with a name: testing.c 

bullet

Compile: The C compiler is usually named cc or gcc, at a command line, type cc/gcc ľo executable_file source_file.  For example, you type:

% gcc -o testing testing.c 

or 

% cc -o testing testing.c 

     testing is the out come executable file name and testing.c is the source file to be compiled  

bullet

Run:

bullet

If you your current working directory in your path, then simply type:

%  testing 

At prompt to execute your c program 

bullet

If you are not sure, type:

%  ./ testing 

Instead.

    

 

Send mail to cscyzl@hofstra.edu with questions or comments about this web site.
Last modified: 09/16/04