std string中有没有类似于CString的getbuffer releasebuffer的函数?
CString的getbuffer releasebuffer我觉得还挺好用的,传入时不需要知道长度
std::string有没有类似的函数?
- C/C++ code
CString str;some_function_change_the_string(str.GetBuffer(0) );str.ReleaseBuffer(0);
[解决办法]
c_str()
?
[解决办法]
你可以通过allocator来访问到string的内存:
- C/C++ code
#include <string>using namespace std;typedef basic_string<TCHAR> tstring;... tstring str(_T("BBB")); tstring::allocator_type tch = str.get_allocator(); tstring::pointer pBuff = tch.address(*(str.begin())); pBuff[1] = _T('A');