Saturday, February 16, 2019

C Program & I/O statements

C Program & I/O statements.

 Structure of C Language program
 // Comments     Optional # Preprocessor
directive   Compulsory Global Variables;
 Optional
 main ( )     Compulsory Function {
Local variables; Statements;
}
 User defined function 1   Optional
Function {
Local variables; Statements;
}
 User defined function 2    Optional
Function
…      User defined function n   Optional
Function

Compilation & Execution of C program 
Preprocessor:    
The source code is firstly passed through
the preprocessor. It expends this code by
performing the preprocessing directives and
then passes it to the compiler.
Compiler:
The expended code is passed to the compiler.
 It converts this code into the machine's
assembly language code.

Assembler:  
It converts the assembly code into object code. The name of the object file is same as
the source file. In DOS the object file has
extension “.obj" and in UNIX the extension
is ' .o „.

Linker:
 Generally, all programs written in c use
library functions.  Library functions are
precompiled and their object code is
stored in library files with ' .lib ' or ' .a '
extension. The linker combines the object
code of the library functions with the object
code of our program.

      Our program may also contain references to 
functions that are defined in other files. The 
linker links the object code of these files also 
to our program. So the job of linker is to 
combine the object code of our program 
with the object code of other files and object 
code of library functions. The output of the 
linker is an executable file. 

No comments:

Post a Comment