我正在做一些维护工作,遇到类似以下的事情:
std::string s;
s.resize( strLength );
// strLength is a size_t with the length of a C string in it.
memcpy( &s[0], str, strLength );
Run Code Online (Sandbox Code Playgroud)
我知道使用&s [0]如果它是std :: vector会是安全的,但是这是std :: string的安全使用吗?