The compilation technique in C includes several steps that remodel human-readable source code into device-executable instructions. (such as C, C++, Java, etc.)
Compilation method in C:
- Preprocessing:
- Preprocessor directives (beginning with #) are processed.
- includes header documents, expands macros, and plays conditional compilation.
- Output: Preprocessed source code.
- Compilation:
- translates preprocessed supply code into assembly code (low-stage human-readable commands).
- checks syntax and semantics for mistakes.
- Output: assembly code.
- Assembly:
- Converts assembly code into system-readable item code.
- Output: object code (system code in binary format).
- Linking:
- Combines object code with libraries and resolves outside references.
- Produces the final executable report.
- Output: Executable report (.exe in home windows, or with out extension in Linux).
Syntax
// Preprocessor directives
#include <stdio.h>
// Main function
int main() {
// Statements
printf(“Programmer__Coding!\n”);
return 0;
}
Example
#include <stdio.h>
int main() {
printf(“Programmer__Coding!\n”);
return 0;
}
Output
Programmer__coding!
Explanation:
the example program includes the same old input-output library (stdio.h) the usage of a preprocessor directive.
the main() characteristic is the access factor of this system, which prints ” Programmer__Coding!” to the console the use of the printf() function.
The return 0; statement exits the main() function and returns a value of 0 to the running system, indicating a success execution.
This program, while compiled, will produce an executable record that, while run, will display ” Programmer__Coding!” on the console.