Assume that the C program you have written is in the file named
hello.c
Remember that a C program file name should
end
with an extension .c in general. The file that include the C program
(in our case the file hello.c) we will call a
source file or source code.
I assume that you have logged in to the computer and are currently in the UNIX shell. I will omit the UNIX prompt for clarity. First, you should compile your program with the following command:
gcc hello.c a.out ( this
is the executable file/code). Now to run the program, simply type:
a.out Then, your program will run.
It's a good practice to get into the habit of naming your executable files with descriptive names. For example,
gcc -o helloExe hello.cwill compile the program hello.c and produce the executable in a file named helloExe. You can run the executable program as follows:
helloExe