C

1. The Compilation Process

Compilation is the process of converting human-readable code (High-Level Language) into machine-readable code (Binary). This happens in four distinct stages:

  • Preprocessing: The preprocessor handles directives starting with # (like #include). It expands macros and includes the contents of header files into the source code.

  • Compilation: The expanded code is translated into Assembly Level Language, which is a low-level instruction set specific to the computer's processor.

  • Assembly: An assembler converts the assembly code into Object Code (machine code), usually resulting in a .obj or .o file.

  • Linking: The linker combines your object code with library files (like stdio.h functions) to create a single Executable File (e.g., .exe on Windows or .out on Linux).

2. The Execution Process

Once the executable file is created, the execution phase begins:

  1. Loading: When you run the program, the Operating System's Loader brings the executable file from the hard drive into the RAM (Random Access Memory).

  2. Entry Point: The CPU starts executing instructions beginning at the main() function.

  3. Instruction Cycle: The CPU follows the "Fetch-Decode-Execute" cycle for every line of code until the program hits a return statement or the end of main().

Summary Table

StageInputOutputPurpose
Preprocessing.c file.i fileHandles # directives and macros.
Compilation.i file.s fileConverts C to Assembly code.
Assembly.s file.o / .objConverts Assembly to Machine code.
Linking.o files.exe / .outMerges code with libraries.
ExecutionExecutable
Upcoming Course
Upcoming Course
Learn More
Instructor Tips
Instructor Tips
View Tips
Join Community
Join Community
Join Now