#include "stdafx.h"#include "iostream"#include "String"int main(){ std::string a; a = "212121"; char *p; a.copy(p, 5, 0); *(p + 5) = '\0'; (std::string)p; std::cout << p<<"\n"; system("pause"); return 0;}说是a.copy(p,5,0)错了,我也不知道哪里不对。
如你所示,我尝试了一下,还是报错,错误如下。我用的是VS2017.
我开辟空间还是错了,是不是因为新的C++标准中,safe函数修改了导致的报错。我用的VS17
追答有可能,我是vs2013,没报错。