The simplest hello world program you can write in C.

This is a very simple Hello World program that you can write in C.

int main (void) {
 
    write (1, "Hello World\n", 14);
    return 0;
}

Just compile the program like this:

localhost% cc minimal.c -o small
minimal.c: In function ‘main’:
minimal.c:2:5: warning: implicit declaration of functionwrite[-Wimplicit-function-declaration]
     write (1, "Hello World\n", 14);
     ^~~~~

Then execute it to get the output. This is very easy.

localhost% ./small 
Hello World

This little program is very small indeed.

localhost% ls -hula ./small 
-rwxr-xr-x. 1 jason jason 8.4K May 25 09:28 ./small

I wonder if you could strip this program down even more and make it even simpler. An interesting exercise indeed.

No comments have been made. Use this form to start the conversation :)

Leave a Reply