Sunday, July 12, 2009

When i compile c/c++ program i get2errors, unable 2open include file and cannot display output.wht should i do

------------


1)


If all files are located in the same directory, then





#include "xxx.h"





...should find that header file just fine.





But, if you have:





#include %26lt;xxx.h%26gt;





...then you need to specify a search path.


---------------------





The Help files say this about the #include statement:





"The command looks for the include files requested by MAIN.c in the following order: first in the directory containing MAIN.c, then in the \INCLUDE directory, then in the \MY\INCLUDE directory, and finally in the directories assigned to the INCLUDE environment variable.


______________________________________...





2)





%26lt;iostream.h%26gt; is deprecated (rarely used). It's routines are limited to C style string (char) functionality. It's only 'value' is for some legacy code. Instead, you should only use %26lt;iostream%26gt;.





The standard C++ headers do not have .h extensions. You're probably using a deprecated header if you include %26lt;string.h%26gt; or %26lt;vector.h%26gt;.





That said, if you wish to include a standard C header, stick a 'c' prefix on it and remove the 'h.'





%26lt;stdio.h%26gt; is incorrect; however, %26lt;cstdio%26gt; is correct.


No comments:

Post a Comment