
成功解决:‘scanf‘: This function or variable may be unsafe. Consider using scanf
运行C程序时报错:
错误 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.
原代码:
scanf(" %c", &c);将scanf换成scanf_s后调试程序
scanf_s(" %c", &c);调试程序时报警告
警告 C6064 缺少“scanf_s”的整型参数(对应于转换说明符“2”)
scanf_s在使用%c和%s读入字符或字符串时,应在地址参数后附加一个缓冲区边界值。
scanf_s(" %c", &c, sizeof(c));再次运行程序,警告消失,问题解决
成功解决:‘scanf’: This function or variable may be unsafe. Consider using scanf_s instead 的问题
欢迎小伙伴讨论,如有错误请在评论区评论或发私聊消,谢谢你。
👁️ 阅读量:0
© 版权声明:本文《成功解决:‘scanf‘: This function or variable may be unsafe. Consider using scanf》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686554699a290580.html。