- Step 1. Compile the program.
gcc -o hello hello.c
This command will invoke the GNU C compiler to compile the file hello.c and output (-o) the result to an executable called hello.
- Step 2. Execute the program.
./hello
This should result in the output
Hello World
- Step 3. (Optional)
In order to avoid the ./
prefix each time a program is to be executed, insert the following as the last line in the file .profile
(located in your home folder):
export `PATH=.:$PATH`
This step needs only to be done only once.
- Step 1. After you have saved the program file, type the command to compile:
g++ program.cc –o program
- Step 2. To run the program, type:
./program