C/Unable to Include #include
Expert: Prince M. Premnath - 11/30/2009
Questioni wrote 1 st program in c but compiler giving me error enable to include file stdio.h what went wrong
which file extention is used to save c programs .c or .cpp
AnswerHi Dear shreyas!
Usually a beginner used to get these kind of problems , ie errors like unable to include files , here ill explain you why !
In your C/C++ programs u might use some functions , upon using this you have to declare those , if in case its a function you have to declare function prototypes , these declarations are available in header files
eg : the definition for the object 'printf()' is available in the header file stdio.h
So once if you compile a program , the compiler tries to make reference with those header files, matter of fact compiler don't know the exact locations of header files , By default the compiler vendors will guide the compiler by providing path names. by mistake if there is a change in the path name , then the compiler fails to make a reference with the header file
if so you used to get the familiar error message in Turbo C/C++
Error : Unable to include stdio.h and so on .
Solution :
Try to find the path where the header files are stored ( hope it will be available under TC\INCLUDE\ directory
Open the OPTION menu from your IDE select Directories , there you supposed to enter the absolute path where your header files stored in your disk .
eg:
Include Directories:
D:\TC\INCLUDE
Library Directories:
D:\TC\LIB
Assume that ive installed my C/C++ Compiler in D:\TC\ folder , check out the image attached with this answer
Enter the path name , press OK
Re-compile the program , sure you won't get any errors
Thanks and Regards
Prince M. Premnath
Note: Revert me in case of issues .