include files in turbo c++ 3.0 (dos version)

i'm using tc++ 3.0.
as far as i know, if i place a statement:
#include "file.h"
in my source, the compiler will search the "file.h" in the directory that my source locates.
if i place:
#include <iostream.h>
the compiler will go the the "include" directory that I set in the Option->Directories.
however, now i open a source in a dir "c:\temp", this file includes the "file.h" which are in c:\temp too.
but i can run the program, the compiler said:
"unable to open the include file "file.h".

so what should i do in order to run the program successfully?
(i'm using the tc++ 3.0 under win98.)

Who is Participating?
newexpertConnect With a Mentor Commented:
Goto File Menu -> Change Current Path to C:\TEMP
Assuming you "include paths" are set correctly, which is doubtful, as you program should work. Have you tried #include "c:\temp\file.h" to see if it works?

When you say yoou open the source in c:\temp, do you mean you also included that file in your project, or is another copy of the source sitting somewhere else?
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Assuming your directories are configured correctly Options->Directories, include should be C:\TC\INCLUDE (or whatever your directory is), that shouldn't be the problem.

Take these steps:

1) Make sure C:\TC\BIN is in your path
2) Go to the directory where you want to compile
3) Make sure file.h exists
4) Run TC.EXE (this will work if it's in your path!:)
5) Open up your program
6) Make sure it says EXACTLY   #include "file.h"
7) Run it

This should work, if by some odd reason it doesn't, RECHECK the spelling of the header file you're including (file.h) vs. the actual file name. If it's all correct, try putting file.h into the c:\tc\include directory, and using #include <file.h>, that's all I can think of. If you follow those steps, you should be fine. If all else fails, just re-install Turbo C++ :)

chuyanAuthor Commented:
I have tried, but it still doesn't work.

I know copying the .h file into the include directory will work, but i just want to avoid doing that.
so........any other methods can help?
There 2 2 possibility make this:
1.You must write in you's c:\temp  files:
  #include "c:\maindir\file.h" (if you h file in maindir)
 With such include translator find h files in exactly place
2. in you's c:\temp  files:   "c:\temp\file.h" (if you h file in temp)
Regards, Alex
chuyanAuthor Commented:
sorry alex,
your answer is more or less the same as b4.

chuyanAuthor Commented:
now, it seems that my problem is solved by entering the exact path of the header file (e..g #include "c:\temp\file.h".
i can compile <press alt-F9> the source file successfully.  However, when i run the file by pressing ctrl-F9, errors appeared.  sometimes it will say "undefined symbol xxxx::xxx() in module xxxxxxxxxxxxxxxxxxxxxxxxxx"
but i'm sure that the function is properly defined in the class defined in the header file.
so can anyone tell me what's happenning?

Tks alot!!

You still have serious problem there chuyan, You shouldnt have to use the absolute path.
Ive no idea what it is though?

The undefined symbol is indicating 1) either the cpp source is not identified as part of the project,
2) possibly the function definition is not identified as a member of the class with the scope resolution operator  MyClass::theFunction() { ... }
3) the function signature does not match,  perhaps return type is missing or differnet or an argument type is missing or different.

My suggestion,
start a new project, include all the source files into the new project as you expect them to be, turn up all the warning levels to maximum and do a rebuild all, both in debug and release..  

Post the project files somewhere.  I am curious as to why Borland is having such difficulty recognizing the basic include functionality

chuyanAuthor Commented:

can i ask you sth first? does TC++ 3.0 support the data type "bool"?

bool wasn't defined as part of ANSI C standard.
Some standard libraries might impliment it.  It is included in proposed ANSI C++ standard.

Common practice is to typedef BOOL as a short or enum it.
enum BOOL (FALSE = 0, TRUE) is more restrictive as an enum since TRUE can only be 1, where in the more traditional sense TRUE is consider anything non zero.

More Flexible is
#define FALSE 0
#define TRUE !FALSE

depends somewhat on your style
I agree with the earlier comment that you should specify the path for your header file.  However the poster forgot to do double backslashes, instead of single.


#include "c:\\temp\\file.h"

chuyanAuthor Commented:
sorry, single back slash is ok already.
chuyanAuthor Commented:
All Courses

From novice to tech pro — start learning today.