天天看點

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中。