- Get link
- X
- Other Apps
Files used in C program
C program has four kinds of files associated with it
Source code file
The source code file contains the source code of the program. The file extension of any C source code file is '.C'. This file contains C source code that defines the main function and maybe other functions. The main () is the starting point of execution when you successfully compile and run the program. A C program is general may include even other source code files.
Header Files
when working with large projects. It is often desirable to separate out certain sub routines from the main() of the program. There also may be a case that same subroutine has to be used in different programs. In the later case, one option is to copy the code of the desired sub-routine from one program to another. But copying the code is often tedious as well as error prone and makes maintainability more difficult. Another option is to make subroutine and store them in a different file known as header file. The programmer wants to change or add subroutines, and have those changes reflected in all the other programs. In this case, he just need to change the source file for the subroutines, recompile its source code, and then recompile and re-link programs that use them. This way enormous time can be saved as compared to editing the subroutines in every individual program that uses them. Header files names ends with a 'dot h'(.h) extension and its name can use only letters, digits, dashes, and underscores. Although some standard header files are automatically available to C programmers but in addition to those header files, the programmer may have his own user defined header files.
Standard Header Files Example of standard header files
- string.h : For string handling function
- stdlib.h : For some miscellaneous function
- stdio.h : For standardized input and output functions
- math.h : For mathematical functions
- alloc.h : For dynamic memory allocation
- conio.h : For clearing the screen
Object Files
Object file are generated by the compiler as a result of processing the source code file. Object files contain compact binary code of the function definitions. Linker uses this object file to produce an executable file(.exe file) by combining the object file together. Object files have a '.o' extension, although some operating system including Windows and MS-DOS have a '.obj' extension for the object file.
Executable file
The binary executable file is generated by the linker. The linker links the various object files to produce a binary file that can be directly executed. On Windows operating system, the executable files have '.exe' extension.
Comments
Post a Comment