C Execution Process
This articles explains the steps involved in executing a C program.
To execute a C program, the source code should be saved with a ".c" extension. The preprocessor is responsible for interpreting certain lines of code, which begin with the "#include" directive followed by specific libraries such as "stdio.h" and "string.h". These lines are not understood by the compiler, but the preprocessor replaces them with the appropriate function declarations, resulting in an expanded source code.
The compiler then compiles the program and generates an assembly file. The assembler converts the assembly language into object code, creating an object file. However, the object file is not ready for execution.
The linker comes into play, linking all the object codes and system libraries into one file. This file contains the definitions of predefined functions, resulting in an executable file.
The loader then loads the executable file into the main memory (RAM), and the execution of the program begins. If there are no errors, the output will be displayed.