INTERVIEW QUESTIONS
C
C BASICS
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 <macros.inc>
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.
|
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 <macros.inc>
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
Yes, off course you can add any file using #include for example: # include "Timer.c" is a c file which implements time functions. You can add your other c files if you need them too. Source: CoolInterview.com
Answered by: Abhishek | Date: 2/11/2010
| Contact Abhishek
yes,we can include the all standard def functions by using " "........ ex: #include"math.c" for include the library fun we hane two ways in c... 1.#include<file.h> 2.#include"file" Source: CoolInterview.com
Answered by: chitra | Date: 8/1/2010
| Contact chitra
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.
|