我正在以这种方式将一个较小的数组复制到一个较大的数组中
int *Arr // this points to array that has size of 7 (i.e) int Arr[7];
int size // this has the size of the above ie. 7
现在我想制作一个更大的数组并复制以前的数组数据,所以我这样做
int *nArr = new int[size+1];
这是问题开始的地方我正在尝试使用 std::copy 复制内容 我正在使用 C++03,所以我无权访问 std::begin 和 std::end
std::copy ( Arr, Arr+size, nArr);
上面的语句给了我错误
Error 1 error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility 2176
最佳答案
看起来微软很挑剔。只需禁用警告;你的代码没问题。
关于c++ - 使用 std::copy 将一个数组复制到另一个数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22581959/