Introduction to C
C is a small, fast, compiled programming language from the early 1970s that still sits underneath almost everything: operating system kernels, databases, embedded devices, language runtimes and the libraries other languages call. Learning it teaches you how a computer really handles memory and data — knowledge that makes you better in every other language.
What C is used for
- Operating systems — the Linux, Windows and macOS kernels are largely written in C.
- Embedded systems — microcontrollers in cars, washing machines, routers and medical devices.
- Infrastructure software — SQLite, the Python interpreter (CPython), Git, Redis, curl and many web servers.
- Libraries for other languages — Python, Ruby, Node.js and others call C code for speed and to reach the operating system.
- Performance-critical code — compression, cryptography, graphics, scientific computing.
A first look
#include <stdio.h> int main(void) { printf("Hello, C!\n"); return 0; }
Hello, C!
This is a complete C program. You write it in a text file ending in .c, a compiler translates it into machine code, and you run the result. Lesson 3 explains every line.
Why learn C?
- It shows you how computers work. In C you manage memory yourself and see exactly how numbers, text and data structures are laid out in bytes.
- It's fast and small. C programs compile to efficient machine code with almost no overhead, and run on practically any processor.
- It's everywhere. C compilers exist for nearly every device ever made, and its syntax inspired C++, Java, C#, JavaScript, Go and many more — so it'll feel familiar later.
- It lasts. Well-written C from decades ago still compiles today.
The trade-offs
C gives you power and trusts you completely. It doesn't check array bounds, doesn't clean up memory for you, and lets you do things whose results are not defined at all — what C calls undefined behaviour. Mistakes can crash programs or create security holes, which is why newer languages such as Rust add guarantees C doesn't have. This course teaches careful, modern C: compiler warnings turned on, safe library functions, and a whole lesson on avoiding undefined behaviour.
A short history
Dennis Ritchie created C at Bell Labs between 1969 and 1973 to rewrite the Unix operating system, which made Unix portable to new machines. The 1978 book The C Programming Language by Brian Kernighan and Ritchie spread it widely. C was then standardised, and each standard is named after its year:
| Standard | Highlights |
|---|---|
| C89 / C90 | The first ANSI/ISO standard ("ANSI C") |
| C99 | // comments, bool, stdint.h, declarations anywhere, variable-length arrays |
| C11 | Threads, atomics, _Static_assert, anonymous structs |
| C17 | Bug fixes to C11 — the most widely supported modern standard |
| C23 | bool/true/false as keywords, nullptr, constexpr, typeof, binary literals and more |
This course writes C17 code, which every current compiler supports, and covers the newer C23 features in lesson 55.
How this course works
Every example was compiled with a real C compiler (Clang 17, with warnings enabled) and run, and the output shown is exactly what it printed. The Try it yourself boxes let you edit an example and copy it to compile on your own computer. Set up a compiler in the next lesson so you can follow along.
Try it yourself
Change the message and add a second printf line. Copy the program and keep it ready — you'll compile it in the next lesson.
Hello, C! I am learning C.