天天看点

VC7(VS2002)调试时 std::string 超过15字符乱码问题

VC7(VS2002)调试时 std::string 超过15字符乱码问题

VC8(VS2005)无此问题。

std::string str = "1234567890123456";        

const char* p    = str.c_str();

调试时:str的值是乱码,p是正确值。

可能是VS2002的bug,根源可能是:

std::string 不超过15字符保存在_Bx.Buf中,否则保证在_Bx.Ptr中。