What you'll learn
C puts you close to the machine without forcing you to write raw processor instructions. In this first lesson, you'll build a precise mental model of how C programs are created, install the essential tools, and compile your first native executable.
By the end, you'll be able to:
- Explain what makes C different from interpreted and virtual-machine languages
- Describe preprocessing, compilation, linking, and execution
- Compile a warning-clean C17 program with GCC or Clang
- Read the essential parts of a small C source file
How to use this course
What is C?
C is a general-purpose programming language created by Dennis Ritchie at Bell Labs in the early 1970s. It was designed to build Unix, so it combines readable structured code with direct access to memory and hardware-friendly data.
C is small by modern language standards. It does not include classes, garbage collection, exceptions, or a huge built-in library. That simplicity gives it an enormous reach: compilers can target tiny microcontrollers, desktop computers, servers, and supercomputers.
Key idea
Where C is used
You may not see C on a screen, but you use software written in C constantly. It thrives wherever predictable performance, a small runtime, portability, or hardware access matters.
Operating systems
Linux · Windows · kernels
Embedded systems
Cars · sensors · appliances
Language runtimes
CPython · compilers · VMs
Infrastructure
Databases · servers · networks
Games & graphics
Engines · drivers · libraries
Everyday libraries
Git · SQLite · curl
Learning C also improves your understanding of other languages. Arrays, references, object lifetimes, stack frames, binary data, and operating-system APIs become less mysterious once you have worked with their foundations directly.
How C becomes a program
A C source file is text for humans. Your processor needs machine instructions. A toolchain transforms one into the other:
- The preprocessor handles directives such as
#include. - The compiler checks and translates C into lower-level instructions.
- The assembler creates an object file containing machine code.
- The linker combines your object code with required libraries.
- The operating system loads the resulting executable.
Note
Compiler & editor setup
Install either GCC or Clang. On Windows, a convenient route is MSYS2, WSL, or a native LLVM installation. On macOS, install the Xcode Command Line Tools. Linux distributions provide GCC or Clang through their package manager.
Open a fresh terminal and verify that at least one compiler is available:
gcc --version
clang --versionUse an editor that can show diagnostics and navigate code, but keep the terminal workflow. VS Code with a C extension, CLion, Visual Studio, and many lighter editors are all valid.
Your first program: Hello, World!
Create a file named main.c. C source files conventionally use the.c extension:
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
return 0;
}Compile it with strict warnings enabled, then run the executable:
gcc -std=c17 -Wall -Wextra -Wpedantic main.c -o hello
./helloKeep the warnings
-std=c17 selects the language standard. -Wall -Wextra -Wpedanticasks the compiler to explain suspicious code. Use these flags throughout the course.Anatomy of a C program
#include <stdio.h>makes declarations for standard input/output available.int main(void)defines the program's starting function.- Braces create the function body—a block of statements.
printfwrites formatted output;\nstarts a new line.return 0;tells the environment that the program succeeded.- Most C statements end with a semicolon.
C is case-sensitive
main, Main, and MAIN are different identifiers. Standard-library names such as printf must use their exact spelling and case.The development workflow
A reliable C workflow is deliberately repetitive:
- Edit one small piece of source code.
- Compile with strict warnings.
- Fix the first diagnostic, then compile again.
- Run the program with normal, boundary, and invalid inputs.
- Save a working checkpoint in version control.
Compiler diagnostics normally include a file, line, column, severity, and message. Start at the first error: later errors are often consequences of one missing quote, brace, or semicolon.
Comments
C supports line comments and block comments. Comments should record intent, constraints, or a surprising decision—not translate obvious code into English.
#include <stdio.h>
int main(void) {
// A line comment ends at the newline.
printf("C rewards precision.\n");
/*
* A block comment can span
* several lines.
*/
return 0;
}Tip
Recap & quick check
Key takeaways
- C is a small, portable systems language that compiles to native code.
- The build pipeline preprocesses, compiles, assembles, and links source files.
- main is the program entry point, and returning zero reports success.
- Strict compiler warnings are an everyday correctness tool.
- The core learning loop is edit, compile, read diagnostics, run, and test.
Quick check
1. Which stage combines object code with required libraries?
2. What does returning 0 from main conventionally mean?
3. Why compile with -Wall -Wextra -Wpedantic?
4. What does #include <stdio.h> provide for this lesson?
Your toolchain is ready. Next up: Module 2 — Variables, Data Types & Operators, where programs begin storing and transforming real data.