阅读背景:

sprintf如何处理CString和std::string

来源:互联网 
CString s = "test";
std::string ss = "test";

char z[100];
sprintf(z, "%s", ss.c_str()); // z = "test"  : OK

char z2[100];
sprintf(z2, "%s", ss); // z2 = "(null)" : OK. undefined behavior is expected

char z3[100];
sprintf(z3, "%s", s); // z3 = "test" : How is this possible ?!
CString s = "test";
std::string ss = "test";

c



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: