In C programming, different types of files are used during writing, compiling, linking, and running a program. Each file has a specific purpose and a different file extension. These extensions help programmers and compilers identify the role of each file in the C program development process.
| File Type | File Extension | Description |
|---|---|---|
| Source Code File | .c |
This file contains the actual C program written by the programmer. It includes functions, variables, statements, and program logic. |
| Header File | .h |
Header files contain function declarations, macros, constants, and structure definitions.
They are included in source files using the #include directive.
|
| Object File | .o or .obj |
Object files are created after successful compilation of the source code. They contain machine-level code but are not directly executable. |
| Executable File | .exe |
This file is created after linking object files and required library files. It is the final file that can be executed or run by the computer. |
For example, if a C program is saved as program.c, the compiler first converts it into an object file
such as program.o or program.obj. After that, the linker combines the object file with
required library files and creates the final executable file such as program.exe.
Therefore, the main file extensions involved in C programming are .c for source code files,
.h for header files, .o or .obj for object files, and .exe
for executable files.