<fstream> problem with Borland Builder 6.0
I am getting strange errors when I include <fstream> under BB 6.0.
The following minimal program produces the error:
----------------------------------------------
#include <fstream.h>
void main ()
{
// read the propagation data
int inDims;
ifstream infile("C:\Documents and Settings\ChristianZ\My Documents\Software\vtk\examples\map scroll\infile.var");
infile.read((char*) &inDims,4);
}
-------------------------------------------------
BB 6.0 complains:
[C++ Error] except.h(118): E2316'exception' is not a member of 'std'
[C++ Error] except.h(118): E2303 Type name expected
[C++ Error] _ios_base.h(48): E2303 Type name expected
[C++ Error] iso.cpp(8): E2451 Undefined symbol 'ifstream'
[C++ Error] iso.cpp(8): E2379 Statement missing ;
[C++ Error] iso.cpp(8): E2451 Undefined symbol 'infile'
Can anybody help me with this problem?
Thanks,
Christian
Re: <fstream> problem with Borland Builder 6.0
Isn't it "#include <fstream>" (no ".h")?
Viggy
Re: <fstream> problem with Borland Builder 6.0
You are right, but I tried with and without ".h", the problem remains the same.
-C
Re: <fstream> problem with Borland Builder 6.0
Quote:
Originally Posted by zemlinc
[C++ Error] except.h(118): E2316'exception' is not a member of 'std'
[C++ Error] except.h(118): E2303 Type name expected
[C++ Error] _ios_base.h(48): E2303 Type name expected
[C++ Error] iso.cpp(8): E2451 Undefined symbol 'ifstream'
[C++ Error] iso.cpp(8): E2379 Statement missing ;
[C++ Error] iso.cpp(8): E2451 Undefined symbol 'infile'
Can anybody help me with this problem?
Thanks,
Christian
The error seems to be in except.h. Do you have these errors when you dont use #include<fstream> ?
Re: <fstream> problem with Borland Builder 6.0
Quote:
Originally Posted by zemlinc
You are right, but I tried with and without ".h", the problem remains the same.
-C
Did you remember to use namespace std? Also main() returns an int.
It seems you are using material that is at least 10 years old. Usage of fstream.h has been deprecated, and the standard header is <fstream>. Get more modern C++ books and tutorials.
Also, the title of the thread is misleading, since you originally did not use <fstream>, but <fstream.h>. They are not the same thing.
Code:
#include <fstream>
int main()
{
std::ofstream ifs;
}
Does this compile? Note the std:: namespace.
Last, this string contains illegal escape sequences:
Quote:
"C:\Documents and Settings\ChristianZ\My Documents\Software\vtk\examples\map scroll\infile.var")
"\D", "\C", etc. are not legal escape sequences. Look at the third character in the string -- it is a "\D".
The correct string is this:
Quote:
"C:/Documents and Settings/ChristianZ/My Documents/Software/vtk/examples/map scroll/infile.var")
Forward slashes are used as directory separators for standard I/O functions.
Regards,
Paul McKenzie
Re: <fstream> problem with Borland Builder 6.0
If I recall correctly some of the early Borland headers had dependancies (which they should not). Figure out what you need to make the following compile:
Code:
#include <ThisIsWhatYouFigureOut>
int main()
{
try
{
throw std::exception("Error");
}
catch (std::exception ex)
{
}
}
Once you have a valid header set for this, put those headers beofre the #include of <fsstream> in your original sample....
Re: <fstream> problem with Borland Builder 6.0
bro. CPUWIZARD can u tell me what is the advantage of using using namespace std::
Re: <fstream> problem with Borland Builder 6.0
Quote:
Originally Posted by nitin1979
bro. CPUWIZARD can u tell me what is the advantage of using using namespace std::
All of the STL (Standard Template Library) is in the std namespace. Writing modern C++ programs without using the STL, is just plain silly.