Running this program in VS 2013 will produce the following error:

1>error C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

C4996 error is a warning in Visual Studio indicating that you are using a function or feature that has been marked as "deprecated". Usually, it will suggest you use a safer or more modern alternative.

Here are several solutions:

1. Use recommended replacement functions

Visual Studio usually provides a suggested replacement function. For example, strcpy is considered unsafe, and strcpy_s can be used as an alternative.

Example

// Deprecated usage
char dest[100];
strcpy(dest, "Hello, World!");

// Recommended usage
char dest[100];
strcpy_s(dest, sizeof(dest), "Hello, World!");

2. Disable specific warning

If you are sure that using a certain function is safe, but still want to disable this warning, you can use the following#pragma warningdirective.

Example

#pragma warning(disable: 4996)

#include <cstring>

int main() {
    char dest[100];
    strcpy(dest, "Hello, World!");
    return 0;
}

3. Globally disable warning

If you want to globally disable this warning, you can set it in the project's properties:

Right-click the project and select "Properties".

Under "C/C++" -> "Advanced", find the "Disable Specific Warnings" option.

Enter 4996 in the "Disable Specific Warnings" field.

4. Modify compiler definitions

In some cases, modifying the compiler's macro definitions can also solve the problem. You can use#defineto ignore specific warnings.

Example

#define _CRT_SECURE_NO_WARNINGS
#include <cstring>

int main() {
    char dest[100];
    strcpy(dest, "Hello, World!");
    return 0;
}

Choosing the appropriate method usually depends on your requirements for safety and code. If possible, it is recommended to use safer functions to replace those marked as deprecated.