Many Windows API, such as GetModuleFileName, etc… write output to char* buffer. But it is more convenient to use std::string. Is there a way to have them write to std::string (or std::wstring)’s buffer directly?
Sorry for my poor English. I’m not a native English speaker. -_-
Taworn T.
If you’re using C++0x, then the following is guaranteed to work:
Before C++0x the std::string contents is not guaranteed to be consecutive in memory, so the code is not reliable in theory; in practice it works for popular STL implementations.