I am updating a C++ program, part of which copies arrays of doubles by iterating through each array (copies elements of array wa2 into array X):

for (j = 0; j < N; ++j) {
        X[j] = wa2[j];
} // End for j

I would like to use the built-in function copy, so am going through the program replacing all loops with copy:

copy(wa2, wa2 + N, X);

However, this causes my compiler to complain:

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'

I have gone through this program and am sure the limits of the copy are fine. But I don't know how to turn off this check so that compilation can complete and this program can be executed. I have never tinkered with compiler options before. Any suggestions? (I am using Microsoft Visual Studio Express 2013 for Windows Desktop.)

First thing I'd suggest is to upgrade your version of VS. The support for c++ is much better.

As to your particular problem try this post

First thing I'd suggest is to upgrade your version of VS. The support for c++ is much better.

Yes, I am considering that. Maybe before I start the next project. I hesitate because I don't think it's an upgrade of my existing program; it's a completely new install. I've already got three versions on my computer. I'd like to avoid a fourth. Too much clutter on my computer already. If it was simply an update of my existing version, I'd jump right on it.

As to your particular problem try this post.

Thanks.
I added the following line to the very top of the program and the problem has gone away:

#define _SCL_SECURE_NO_WARNINGS

Excellent! The program is working properly again with no hiccups.

Thanks for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.