Open a text editor to a new blank page and type exactly (CASE sensitive):
// This is a comment so is ignored - note the syntax to start one
#include <stdio.h>
int main()
{
printf("Hello World! \n");
return 0;
}
Save the file with the name hello.c (remember the directory path where it is saved).
Note "hello.c" is still an ordinary text file, and a computer will treat as such. So the
the only action that can be done with "hello.c" is to open it for further editting the text.
In computer terminology "hello.c" is also known as a source file containing source code .
To turn this file into a C program, it has to be converted from text to computer code
out to another file via a process called compiling . To do this open a terminal to the shell
command line. Change directory to where "hello.c" is located. Then type this command
to compile it:
gcc -o hello hello.c
From this, a new file simply named hello is created in the same place "hello.c" is located.
To test and run this new C program, type: