I am trying to create a Windows Forms Application in Visual C++ 2010. I have saved some particular string in string variable "stat" like:
System::String ^stat = "sample string";
The problem is, I cannot write it to a text file using ofstream. When I try this:
if ( opstat == true ) // opstat is a bool variable
{
ofstream outf("mytxt.txt",ios::app);
outf << stat;
outf.close();
}
Compiler returns an error:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion)
And a huge error that goes on forever like:
1> D:\Development\Visual Studio 2010\VC\include\ostream(447): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
What am I supposed to do here?
P.S. I have already included all necessary headers (or the ones I think are necessary) like string, fstream, istream, iomanip etc.