All C source code files must have a .c file extension.
- 2 -
Enter the following program:
#include <stdio.h>
int main()
{
int index;
for (index = 0; index < 7; index = index + 1)
printf ("Hello World!\n");
return 0;
}
- 3 -
Press Ctrl+O to save the file and Ctrl+X to exit.
- 4 -
Enter:
gcc -o myprog firstprog.c
...to create an executable called myprog from your source code (firstprog.c).
Here's a detailed discussion of the line above:
- gcc (GNU C Compiler) is passed...
- ...-o which means give the executable the name that follows (i.e. myprog)...
- ...and the program to compile (referred to as the "source code") is firstprog.c.
- 5 -
To run the program, enter:
./myprog
|