Home > Back-end >  VS2019 development C language problem
VS2019 development C language problem

Time:11-22


Why this program as shown in the scanf function at runtime error? Where is my write wrong?

CodePudding user response:

To define _CRT_SECURE_NO XXX can ignore this warning,
Because of this function is not safe, have already abandoned

CodePudding user response:

Why don't see an error message, use what home

CodePudding user response:

See error message is the building of the compiler does not support the scanf need using scanf_s (vs. support),

Changing the scanf to
 scanf_s (" % d ", & amp; X); 

Try ~

CodePudding user response:

# define _CRT_SECURE_NO_WARNINGS
# pragma warning (4996) disable:

CodePudding user response:

references of the dream life (4th floor response:
# define _CRT_SECURE_NO_WARNINGS
# pragma warning (of which: 4996)

If use # define this sentence must be put in the first line of the program

CodePudding user response:

VS set # define _CRT_SECURE_NO_WARNINGS (solve C4996 error)
1. We are compiling the old open source projects such as lua with C language source package, perhaps because of some old. C files use strcpy, such as the scanf unsafe functions, and submitted to the warnings and errors, and lead to can't compile,
2. Right now we have two solutions:
A. definition: at the beginning of the specified source file # define _CRT_SECURE_NO_WARNINGS (will only play a role in the file)
B. set in the project properties, it will take effect in the whole project, in turn options: attribute - & gt; Configuration properties - & gt; C/C + + - & gt; The preprocessor - & gt; The preprocessor definitions - & gt; Edit
At the bottom with one line: _CRT_SECURE_NO_WARNINGS (note that don't need a # define
This fact can be found online to answer

CodePudding user response:

Error actually already very explicit solution is given

CodePudding user response:

Thank you so much for bosses. I've learned
  • Related