c language basics scanf C4996 scanf maybe unsafe

Asked 1 weeks ago, Updated 1 weeks ago, 0 views

It's a basic code, but I don't know why there's an error ㅜㅜ/

c scanf

2022-09-20 12:34

1 Answers

scanf() is likely to cause misbehavior due to programmer error. This can be used as a means of executing the desired command by an attacker and is vulnerable to security.

Therefore, Visual Studio strongly recommends that you use scanf_s() instead of allowing scanf() by default.

If you want to use scanf() as in the error message in C4996, you can define _CRT_SECURE_NO_WARNINGS at the top, or define the preprocessing macro in the project property as follows:

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
//..

If you want to use scanf_s() for this, you can write it as follows:

scanf_s("%d", &ysalary);


2022-09-20 12:34

If you have any answers or tips


© 2022 pinfo. All rights reserved.