代码
int num;
printf("Please enter three number:\n");
scanf("%*d %*d %d", &num);
printf("The last number is %d\n", num);
return 0;
报错内容
error 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.
用的vs吗 “error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. ”,这个意思是在vs里面用scanf不安全,让你用scanf_s代替,就把代码中scanf换成scanf_s就行
在#include <stdio.h>
之前加上
#define _CRT_SECURE_NO_WARNINGS
'scanf': This function or variable may be unsafe. Consider using scanf_s instead.
使用scanf_s应该就可以了。
以上仅供参考,希望对题主有所帮助!
详细教程请看博客,可以完美解决这个问题!而且不需要每一次都输入取消报错的代码
《【教程】如何解决vs编译器scanf函数报错问题》https://blog.csdn.net/muxuen/article/details/120958032?utm_source=app&app_version=5.0.1&code=app_1562916241&uLinkId=usr1mkqgl919blen
如果有用,还请采纳一下,谢谢!