So, I’m working on a project, and have some code like this:
string blah="somefile";
ofstream fp;
fp.open(blah);
And it doesn’t work. Apparently, what you need to do when using ofstream’s open method:
fp.open(blah.c_str());
Yes, it looks like what it is. Apparently g++’s iostreams library (gcc 3.2) does not support things that have been part of the C++ standard for years–like C++ STL strings… You have to convert back to a C string.
Last I checked this was 2005, not 1999. You’d have thought someone would have overloaded this by now… I’ve only checked this in g++; will check with Intel’s C++ compiler and Microsoft Visual Studio later, though I’m not sure whether to expect better. What didn’t help me to find this out, of course, is g++’s totally wonderful (sarcasm) compiler error messages…
Recent comments
9 weeks 6 days ago
27 weeks 3 days ago
30 weeks 8 hours ago
30 weeks 2 days ago
48 weeks 1 day ago
1 year 2 days ago
1 year 2 days ago
1 year 2 weeks ago
1 year 4 weeks ago
1 year 4 weeks ago