• +91 9723535972
  • info@interviewmaterial.com

C Interview Questions and Answers

Question - How can you avoid including a header more than once?

Answer - One easy technique to avoid multiple inclusions of the same header is to use the #ifndef and #define preprocessor directives. When you create a header for your program, you can #define a symbolic name that is unique to that header. You can use the conditional preprocessor directive named #ifndef to check whether that symbolic name has already been assigned. If it is assigned, you should not include the header, because it has already been preprocessed. If it is not defined, you should define it to avoid any further inclusions of the header. The following header illustrates this technique: #ifndef _FILENAME_H #define _FILENAME_H #define VER_NUM 1.00.00 #define REL_DATE 08/01/94 #if _ _WINDOWS_ _ #define OS_VER WINDOWS #else #define OS_VER DOS #endif #endif

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners