C Programming - C Preprocessor - Discussion

2. 

In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.h

[A]. During editing
[B]. During linking
[C]. During execution
[D]. During preprocessing

Answer: Option D

Explanation:

The preprocessor replaces the line #include <stdio.h> with the system header file of that name. More precisely, the entire text of the file 'stdio.h' replaces the #include directive.


Sandhya said: (Nov 29, 2010)  
#include is a preprocessor directive(file inclusion)and it includes a file in the program . and as we know that a preprocessor processes our program before execution so the line #include<stdio.h> is replaced by the entire content of the file 'stdio.h' during preprocessing.

Shashank Nalwaya said: (Aug 22, 2011)  
Here the functioning is similar to macros. What actually happens is that before compilation i.e. preprocessing as in macros the macro template is replaced by the macro expansion and than the compilation takes place similarly in this case during preprocessing the content of the file is replaced by the file name and than the compilation takes place.

Shankra said: (Jan 20, 2012)  
Thanks sanhya.

Aditya Sant said: (Aug 17, 2013)  
I thought Linking libraries is done at Linking. whats the fact? what is done at the time of linking?

Yojan said: (Apr 6, 2015)  
I am also having doubt. What will happen during linking? Whether there is linking of called and calling functions?

Dnyaneshwar said: (Jul 19, 2015)  
This is right when we compile the program in the time of period compiler find the libraries to check the code if it is correct or not after that program is ready to give the output when it correctly compile.

Kavi said: (Aug 17, 2016)  
I am also having doubt. What will happen during linking? Whether there is linking of called and calling functions?

Manisha said: (Aug 23, 2018)  
The printf, scanf all those functions in stdio.h get replaced during linking but why the answer is preprocessing?

The preprocessing is all about the replacement of macros, file inclusion, #undef, #if, #endif. Etc.

Can anyone please explain the reason for the answer?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.