Source code and object code are two important forms of a program in the C programming language.
Source code is the original program written by the programmer using C language statements, keywords, variables, functions, and logical instructions.
It is human-readable and can be understood and edited by programmers. In C programming, source code files are commonly saved with the extension
.c.
However, a computer processor cannot directly understand source code because the processor works with machine-level instructions. Therefore, the source code must be translated by a compiler. After compilation, the compiler produces object code. Object code is a machine-level or binary form of the program that is not easily readable by humans, but it can be understood by the computer system during the program execution process.
In simple words, source code is written by humans, while object code is generated by the compiler.
Source code is used for writing and modifying the program, whereas object code is used as an intermediate compiled form before creating the final executable file.
In C programming, object code files are commonly saved with extensions such as .o in Unix/Linux systems or .obj in Windows systems.
| Basis | Source Code | Object Code |
|---|---|---|
| Meaning | It is the program written by the programmer in C language. | It is the compiled form of the source code generated by the compiler. |
| Readability | It is human-readable and easy to understand. | It is machine-readable and not easily understood by humans. |
| Created By | It is created by the programmer. | It is created by the compiler after compilation. |
| File Extension | Usually saved with .c extension. |
Usually saved with .o or .obj extension. |
| Purpose | Used for writing, editing, and understanding the program logic. | Used as an intermediate compiled file before generating the final executable program. |
Therefore, the main difference is that source code is the original C program written by the programmer, while object code is the compiled machine-level form produced from the source code.