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 using scanf_s instead. 最高效解决办法!!

相关文章:

  • 2021-08-30
  • 2021-11-13
  • 2022-12-23
  • 2021-10-27
  • 2021-11-05
  • 2021-10-16
猜你喜欢
  • 2022-01-12
  • 2022-12-23
  • 2021-07-05
  • 2021-09-06
  • 2021-10-29
  • 2021-04-09
  • 2021-04-06
相关资源
相似解决方案