Introduction to C and the Compile-Link-Run Model
What C is, why it still matters, and how source becomes a running program.
What you'll learn
- Explain what kind of language C is and why it's still widely used
- Describe the compile-link-run pipeline: .c source -> object file -> executable
- Identify the parts of a minimal C program: #include, main, return
Explanation
C is a statically-typed, compiled language created in the early 1970s that still underpins most of the software world: operating system kernels, language runtimes, embedded firmware, and the C library that higher-level languages like Python and JavaScript are themselves implemented on top of. Learning C makes memory, pointers, and what a compiler actually does far less abstract.
A C program goes through three distinct stages before it runs. First, a compiler (commonly gcc or clang) translates each .c source file into an object file (.o), machine code with any references to other files left as placeholders. Second, a linker combines one or more object files (plus any libraries they need, like the standard C library) into a single executable. Third, you run that executable. The common command gcc main.c -o main actually does all three steps for you in one invocation for a simple program; ./main then runs the result.
Every C program needs a main function as its entry point: int main(void) { ... }. The int return type is a convention the operating system reads as an exit status -- return 0; conventionally means "success." Anything the program needs from the standard library, like printf, comes in through an #include directive, e.g. #include <stdio.h> for standard input/output functions.
This platform can't safely compile or execute real C code in your browser (see this course's guided-lab notice on every lesson), so instead of a live runner, each lesson gives you real C source code and asks you to work out what it does -- exactly the skill of reading code you'll need constantly as a working C developer, since C gives you very little safety net if you get it wrong.
Guided lab
Predict: A minimal C program
Read this program and predict exactly what it prints when compiled and run.
#include <stdio.h>
int main(void) {
printf("Hello, C!\n");
printf("2 + 2 = %d\n", 2 + 2);
return 0;
}Stuck? Get a hint.
Common mistakes
- Forgetting the `#include <stdio.h>` directive and then being confused why `printf` fails to compile.
- Confusing compiling (translating source to an object file) with linking (combining object files and libraries into one executable) -- they're distinct steps even when one command does both.
- Assuming a compiled C executable is portable across operating systems the way a script might be -- a Linux-compiled binary will not run on Windows or macOS without recompiling.
Knowledge check
Takeaway
A C program's entry point is `int main(void)`; getting from source to a running program means compiling to object files, then linking them into an executable.
Summary
C is a compiled, statically-typed language still foundational to operating systems and other languages' runtimes; source goes through compiling and linking before it can run.
References
Your notes
Notes save automatically.
Finished this lesson?
Mark it complete to track your progress and schedule a future review.
AI tutor
The optional AI tutor isn't enabled in this deployment. All lessons, exercises, quizzes, and search work fully without it.