Hi,
I am fairly new to C++. My problem is that my project won't compile ever since I've added very simple code for file output.
Above is just a chunk of the cpp file. "table" is a CString object containing 280x320 temperature values. I have been able to display a portion of it using an AfxMessageBox function, but I want to save all the values to a file. I am using Visual Studio .NET 2003, and I read somewhere that .NET doesn't have all the necessary library files. That makes NO sense to me but either way, I got myself the header files "iostream.h" and "fstream.h" and added them to my project. I still get the same compiling errors as before, saying (summarized):Code:#include "iostream.h"
#include "fstream.h"
...
...
...
ofstream outfile;
char filename[] = "c:/example.txt";
outfile.open(filename, ios::out);
if (!outfile)
{
cerr << "Can't open output file " << filename << endl;
return;
}
outfile << table << endl;
outfile.close();
return;
Does anyone know what I need to do to get it working? to get it to save "table" to a file"? Have I done something wrong? Thanks.Quote:
error C2065: 'cerr' : undeclared identifier
error C2065: 'endl' : undeclared identifier
error C2065: 'ofstream' : undeclared identifier
error C2065: 'out' : undeclared identifier
error C2065: 'outfile' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'outfile'
error C2228: left of '.close' must have class/struct/union type
type is ''unknown-type''
error C2228: left of '.open' must have class/struct/union type
type is ''unknown-type''
error C2593: 'operator <<' is ambiguous
error C2653: 'ios' : is not a class or namespace name
error C3861: 'endl': identifier not found, even with argument-dependent lookup
error C3861: 'outfile': identifier not found, even with argument-dependent lookup
Chunky