Anatomy of a C program
C is compiled: your source is translated to machine code before it runs. Every program starts at main:
#include <stdio.h> // gives us printf
int main(void) {
printf("Hello, World!\n");
return 0; // 0 means "success"
}
#includepulls in a header with function declarations.printfprints formatted text.\nis a newline – C does not add one for you.- Every statement ends with
;.
Try it
Make the program print:
Hello, C!