← Quiz: Files and Preprocessor: all 10 questions
Quiz: Files and Preprocessor · Question 4 of 10
What is the purpose of a header guard (ifndef … define … endif)?
What is the purpose of a header guard (#ifndef … #define … #endif)?
- A.To make code faster
- B.To prevent the same header from being included twice
- C.To hide functions from other files
- D.To declare main
Answer & explanation
Correct answer: To prevent the same header from being included twice
Double inclusion would cause redefinition errors.
Can you get the rest right without peeking?
Take the timed Quiz: Files and Preprocessor quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →