techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

.Net Interview Questions
C++ Interview Questions
Unix Interview Questions
                              .........More

Download e-Books
C Interview Questions e-book

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
                              .........More

Online Quiz
C Online Quiz
C++ Online Quiz
                              .........More

 

 

  

  Home > C Interview Questions >

Can a file other than a .h file be included with #include?

The preprocessor will include whatever file you specify in your #include statement. Therefore, if you have the line

#include

in your program, the file macros.inc will be included in your precompiled program. It is, however, unusual programming practice to put any file that does not have a .h or .hpp extension in an #include statement.

You should always put a .h extension on any of your C files you are going to include. This method makes it easier for you and others to identify which files are being used for preprocessing purposes.

For instance, someone modifying or debugging your program might not know to look at the macros.inc file for macro definitions. That person might try in vain by searching all files with .h extensions and come up empty.

If your file had been named macros.h, the search would have included the macros.h file, and the searcher would have been able to see what macros you defined in it.

 

Have a Question ? post your questions here. It will be answered as soon as possible.