C Tutorial

Learn C, the "mother of programming languages", from basic syntax to pointers, structures and files.

C is a general-purpose, procedural programming language developed by Dennis Ritchie at Bell Labs in 1972 to write the UNIX operating system. Operating systems, compilers, databases and embedded systems are still written in C.

First C Program

C
#include <stdio.h>

int main() {
    printf("Hello, C!\n");
    return 0;
}
Hello, C!
PartMeaning
#include <stdio.h>Preprocessor directive that includes the standard I/O header (for printf, scanf)
int main()Entry point; returns an int to the OS
printf()Prints formatted output
return 0;Signals successful termination

Compiling and Running

Terminal
gcc hello.c -o hello
./hello
Hello, C!

Compilation Stages

hello.cPreprocessorhello.iCompilerhello.sAssemblerhello.oLinkerhello.exe
The four stages that turn hello.c into an executable

Preprocessing (.c → .i) → Compilation (.i → .s assembly) → Assembly (.s → .o object code) → Linking (.o + libraries → executable).

Features of C

  • Fast, close to hardware (a "middle-level" language)
  • Small set of keywords (32 in C89)
  • Pointers and direct memory access
  • Rich operators and a portable standard library
Track your progress through the C course