VS2015运行出错报告:严重性    代码说明项目文件行禁止显示状态    错误    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”:此函数或变量可能不安全。考虑改用scanf_s。

解决办法

1、右键"*cpp"(源文件)——>属性——>配置属性——>常规,把SDL检查设置成“否”。这种方法适合使用scanf;

2、在使用scanf_s时,可以提供更安全一些的机制 ,以防止溢出 ,对于 %s ,变量地址后要紧跟一个参数,以表示其大小,比如:char ch[5];scanf_s("%s", ch, 5);

-----------------分割线--------------------

有兴趣的同学可以多了解一下scanf和scanf_s函数的区别。

更多推荐

错误C4996 'scanf': This function or variable may be unsafe. Consider us