复制一个阵列到另一个使用std ::复制 [英] Copying one Array into another using std::copy
本文介绍了复制一个阵列到另一个使用std ::复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我复制一个较小的阵列成一个较大的以这种方式
为int *编曲//这点到阵列上的7大小(即)INT编曲[7];
INT尺寸//这具有上述也就是说的大小。 7
现在我想要做更大的阵列,所以我这样做复制previous阵列数据
为int * NARR =新的INT [尺寸+ 1];
这是哪里出了问题开始我想使用std复制内容::复制
我使用C ++ 03所以我不能够访问的std ::开始和std ::结束
的std ::复制(编曲,编曲+大小,NARR);
上面的语句给我的错误
错误1错误C4996:'的std :: _ Copy_impl':与参数,可能是不安全的函数调用 - 此调用依赖于调用方检查传递的值是正确的。要禁用这种警告,使用-D_SCL_SECURE_NO_WARNINGS。请参阅如何使用Visual C ++的文档检查的迭代器'C:\\ Program Files文件(x86)的\\微软的Visual Studio 11.0 \\ VC \\包括\\ xutility 2176
解决方案
添加了preprocessor -D_SCL_SECURE_NO_WARNINGS 在VS的项目和上面的code将汇编。
I am copying a smaller array into a larger in this way
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
Now I want to make a larger array and copy the previous array data so I do this
int *nArr = new int[size+1];
This is where the problem starts I am trying to copy content using std::copy I am using C++03 so I dont have access to std::begin and std::end
std::copy ( Arr, Arr+size, nArr);
The above statement gives me the error
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
解决方案
Add the preprocessor -D_SCL_SECURE_NO_WARNINGS in your VS project and the above code would compile.
这篇关于复制一个阵列到另一个使用std ::复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文