Hello, World! in C

Hello, World! in C

🌐 Auf Deutsch lesen
📅 2026-09-03 ✏️ 2026-09-04 ✍️ Andreas Wittmann 👁️ ... c printf

Almost every programming book and tutorial starts the same way: print the words "Hello, World!" and stop. The tradition traces back to Brian Kernighan, who used it in a 1972 internal Bell Labs tutorial for the B programming language, and it became universal after he and Dennis Ritchie used it as the very first example in The C Programming Language (1978) — the book that defined C for a generation of programmers. Decades later, it is still the first program most people write in a new language, C included.

The program

#include <stdio.h>

int main()
{
    printf("Hello, World!\n");
    return 0;
}
Open in full editor →

#include <stdio.h> pulls in the declaration of printf from the C standard library. main is where every C program starts running, and return 0 tells the operating system the program finished without an error. printf writes its argument to standard output — \n at the end just moves the cursor to a new line afterwards.

Compiling it

On a machine with a C compiler installed, this program is one command away from running:

cc hello.c -o hello
./hello

cc (or gcc/clang, depending on the system) reads hello.c, translates it to machine code, links in the standard library that provides printf, and writes an executable named hello. Running that executable prints the line and exits — the same three steps every C program goes through, whether it is four lines long or four million.

Try it yourself

Edit the code above and press "Compile & Run" — change the string, add a second printf, or make it loop.

Conclusion

There isn't much to Hello World, and that's the point: it exercises the whole chain from source code to running program with nothing else in the way. Once it works, the compiler, the standard library, and the way you're running the code are all confirmed to work too.