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 .cpp extension. For example, I could create a  simple c++ program like the following:  

#include <iostream.h> 

int main(){

  cout << "Hello, world." << endl;

  return 0;

}   

  Saved with a name: testing.cpp 

bullet

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

% g++ -o testing testing.cpp 

or 

% c++ -o testing testing.cpp 

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

bullet

Run:

bullet

If you have 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