From ProgrammingExamples
< Talk:CPP
Revision as of 02:10, 4 July 2010 by Daviddoria (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

string Filename = "Test.bin";
ofstream fout(Filename.c_str());

"Test.bin" is in the static data segment, then copied to a string's buffer, if the string is never going to be modified, why not point to the static data segment like that:
const char* Filename = "Test.bin";
ofstream fout(Filename);

This one I'm not very familiar with at all. You're the boss. Please update the example with these changes (being sure to add some explanatory comments :) ). Daviddoria 06:10, 4 July 2010 (UTC)