Is there a way to get std:string's buffer
问题 Is there a way to get the "raw" buffer o a std::string? I'm thinking of something similar to CString::GetBuffer() . For example, with CString I would do: CString myPath; ::GetCurrentDirectory(MAX_PATH+1, myPath.GetBuffer(MAX_PATH)); myPath.ReleaseBuffer(); So, does std::string have something similar? 回答1: Use std::vector<char> if you want a real buffer. #include <vector> #include <string> int main(){ std::vector<char> buff(MAX_PATH+1); ::GetCurrentDirectory(MAX_PATH+1, &buff[0]); std::string