vs solution to unsafe error reporting of scanf function

One.

Beginners often ask questions, what should I do if the scanf function cannot be used when an error is reported

C4996 ‘scanf’: This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Two. Once and for all solutions
1. Define predefined symbols_CRT_SECURE_NO_WARNINGS

Read the error message carefully, it is not difficult for us to find that the message is like this:

The scanf function is not safe. Consider replacing it with scanf_s. If you don't want to see the error, you can also use _CRT_SECURE_NO_WARNINGS, but adding this sentence every time is too troublesome. Here are two ways to do it once and for all.

You can include this code in every new source file

Method: Search in the VS installation path: newc++file.cpp this file, add the sentence #define _CRT_SECURE_NO_WARNINGS to the file, the .c file created after saving will automatically have this code

2. Turn off the SDL check in the vs configuration, the specific location is
Debug-Debug Properties-Configuration Properties-C/C+±All Options-SDL Check

Guess you like

Origin blog.csdn.net/DR5200/article/details/112426679