|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
C
DETAILS
Question: Can a file other than a .h file be included with #include ?
Answer: 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.
|
|
|
Category |
C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9503 users |
Added on |
9/18/2014 |
Views |
67696 |
Rate it! |
|
|
Question:
Can a file other than a .h file be included with #include ?
Answer:
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. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do you print an address ?
|
View Answer
|
|
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
|
View Answer
|
|
When should a type cast be used ?
|
View Answer
|
|
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
|
View Answer
|
|
How can do search for data in a linked list ?
|
View Answer
|
|
When does the compiler not implicitly generate the address of the first element of an array ?
|
View Answer
|
|
What is page thrashing ?
|
View Answer
|
|
When should the register modifier be used? Does it really help ?
|
View Answer
|
|
When should the volatile modifier be used ?
|
View Answer
|
|
What is the result of using Option Explicit ?
|
View Answer
|
|
Difference between const char* p and char const* p
|
View Answer
|
|
Can you tell me how to check whether a linked list is circular ?
|
View Answer
|
|
How to reduce a final size of executable ?
|
View Answer
|
|
How to reduce a final size of executable ?
|
View Answer
|
|
What is the output of printf("%d") ?
|
View Answer
|
|
What is hashing ?
|
View Answer
|
|
#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }
|
View Answer
|
|
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }
|
} - C Interview Questions & Answers">
View Answer
|
|
#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }
|
} - C Interview Questions & Answers">
View Answer
|
|
void main() { int const * p=5; printf("%d",++(*p)); }
|
} - C Interview Questions & Answers">
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All C Interview Questions & Answers - Exam Mode /
Learning Mode
|