I have a few CString variables that I wish to output to an ofstream, but I can't seem to figure out how to do so. Here's some example code.
I have unicode enabled in VS 2005
CODE:
ofstream ofile;
CString str = "some text";
ofile.open(filepath);
ofile << str; // doesn't work, gives me some hex value such as 00C8F1D8 instead
ofile << str.GetBuffer(str.GetLength()) << endl; // same as above
ofile << (LPCTSTR)str << endl; // same as above
// try copying CString to char array
char strary[64];
wcscpy_s(strary, str.GetBuffer()); // strary contents are correctly copied
ofile << strary << endl ; // same hex value problem again!
Any ideas? Thanks!