I'm stumbling around a little bit here trying to get a feel for
wide/Unicode functionality. I'm pretty up on C++ in general, streaming stuff
not so much.
If I run the following code, I get a zero length file. If I take out
*both* string outputs, I get '123abc' as expected. 'Last error' is always 0,
I get none of the debug error output.
Am I doing something wrong/obvisouly stupid? g++ 3.4.4 on Linux.
#include <iostream>
#include <fstream>
#include <errno.h>
int main()
{
std::string jobby = "Hello \u201Cwotsit\u201D\n";
std::wstring wjobby = L"Hello \u201Cwotsit\u201D\n";
std::wofstream file("jobby.out");
if (!file.good()) std::cerr << "Open error\n";
file << 123;
if (!file.good()) std::cerr << "Write error 1\n";
file << "abc";
if (!file.good()) std::cerr << "Write error 2\n";
file << jobby.c_str() << " normal char 10 is '" << jobby[10] << "'\n";
if (!file.good()) std::cerr << "Write error 3\n";
file << wjobby << L" wide char 10 is '" << wjobby[10] << L"'\n";
if (!file.good()) std::cerr << "Write error 4\n";
file.close();
std::cerr << "\nLast error " << errno << "\n";
return 0;
}
--
========================-
http://www.thalesgroup.com/ -=======================
Neil Bird Principal Engineer | A: Yes
mailto:ne*******@uk.thalesgroup.no.spam.please | Q: Is top-posting bad?
Please replace 'no.spam.please' with 'com' to reply directly.
-=-=-
.... APL is a write-only language. - Roy Keir