Skip to content
Related Articles

Related Articles

C Quiz – 110 | Question 3
  • Difficulty Level : Medium
  • Last Updated : 24 Oct, 2015

Typically, library header files in C (e.g. stdio.h) contain not only declaration of functions and macro definitions but they contain definition of user defined data types (e.g. struct, union etc), typedefs and definition of global variables as well. So if we include the same header file more than once in a C program, it would result in compile issue because re-definition of many of the constructs of the header file would happen. So it means the following program will give compile error.




#include “stdio.h”
#include “stdio.h”
#include “stdio.h”
  
int main()
{
 printf(“Whether this statement would be printed?”)
 return 0;
}

(A) TRUE
(B) FALSE


Answer: (B)

Explanation: It’s okay to include library header files multiple times in a program. But actually the content of the header file is included only once. The way it’s achieved is due to usage of “#ifndef“, “#define” and “#endif”. That’s why it’s recommended to use these preprocesor macros even in user defined header files. For an example and usage of this, please check out the “Discuss it” of this question.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :