error

Hi guys im trying to write a program that keeps track of events using log file(txt files) but i get an error when i use this


studNumber = "..\\Log Files\\"+ edtStudNumber->Text + ".txt"; //
ofstream outFile;
outFile.open(studNumber.c_str(),ios::out);
if (outFile.fail())
{
MessageDlg("The file log could not be created",mtWarning,TMsgDlgButtons() <<mbOK,0);
}
else
{
outFile <<"--------------------------"<<endl
<< studNumber << endl
<<"--------------------------";


frmTest->ShowModal();

}


[BCC32 Error] termsConditions_Unit.cpp(41): E2094 'operator<<' not implemented in type 'ostream' for arguments of type 'AnsiString'
What is the type of "studNumber"?
ohh! sorry about that..is of type ansistring...
Have you overloaded operator << for that type?
@ firedraco: Was that a rhetorical question for the OP?
???? *lost*
Actually what im trying to do is write what is contained in a string variable into a text file...
Does studNumber have to be an ansiString? Can it just be a string? I ask because ofstream objects have no problem working with standard strings.
Since you are using this syntax:

file << someansistring

You will need to somehow tell the computer how to save the string. To do this, you would have to create an overload of operator << for your string type. Or you could just use std::string (since they already provide an overload for you)
im using embacardero builder 2010...which uses ansistrings instead of std strings.....so if i use string it gives me the same error but instead it says arguments of type unicodeString at the end of the error message
GoogleFu produced: http://www.embarcadero.com/products/cbuilder

I personally don't like the sound of Rapid Application Development and C++ IDE being used in the same sentence.

If I want to make a Windows Application quick I just use a template.

@ OP: You need to turn that variable into an std::string. I've never heard of an ansiString so I'm not sure if it could just be explicitly cast but that would be the first thing I would try.
Got the solution from my lecture , i just needed to code studNumber._cstr(); :-)
Topic archived. No new replies allowed.