c++ - 使用 std::copy 将一个数组复制到另一个数组

标签 c++ arrays

我正在以这种方式将一个较小的数组复制到一个较大的数组中

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/

相关文章:

c++ - 编译器在移动构造函数和复制构造函数之间的选择

c++ - 在 Eigen C++ : mix complex matrix and real matrix

来自两个不同数组的字符匹配,尽管它们不同

ios - 如何使用 UILaunchImages Key

C 编码 : Create Char Array, 打印、重新组织并再次打印

c - c中的strcat模拟

python - 检查两个数组是否具有等效行的最快方法

java - 使用 Cassandra Metrics 进行监控

c++ - llvm 5.0 与 llvm::Module::dump() 的链接错误

c++ - Qt和opencv中的人脸检测