解决VS2013中出现类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误
来源:互联网 发布:网络暴力措施 编辑:程序博客网 时间:2024/06/11 21:20
用习惯了VS老版本的人当刚使用VS2013的时候可能总遇到类似于这样的错误:
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.
也就是所谓的安全检查错误。例如下图中就是一个最简单的程序结果出现这种错误。
这个问题一般使用以下几种解决办法:
(1)scanf等类似的函数已经不太安全,要想保证程序的安全性,建议以后采用_s结尾的安全版本,但是很多以前的程序可能还是使用不安全的版本,那么下面给出去掉这种错误提示的几种办法。
(2)在VS中新建项目的时候去掉“安全开发生命周期(SDL)检查”即可将错误转变成警告,使得使用不安全版本也不影响编译和运行,如下图所示。
(3)在头文件包含的最前面,记住是最前面(在include的前面)加上:#define _CRT_SECURE_NO_WARNINGS这个宏定义即可,如下图所示。
(4)在编译的头文件最前面加上:#pragma warning( disable : 4996)即可,类似于上图,此处不再附图。
(5)通过以下步骤Project properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions进入到预处理的定义中,点击按钮 (...),输入:_CRT_SECURE_NO_WARNINGS,使用 "\n" 相隔即可。
总之,如果想完全不做安全检查,就使用(2)中的方法或者(5)中的方法,如果只是对某些文件不使用,可以使用(3)和(4)中的方法,个人喜欢使用(2)中的方法,大家可以根据按需选择,不过随着安全性的重要程度在逐步提高,还是建议大家以后使用安全版本。
- 解决VS2013中出现类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误
- 解决VS2013中出现类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误
- 解决VS2013中出现类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误
- Visual Studio 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- VS 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- Visual Studio 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- vs2013 error c4996: This function or variable may be unsafe
- VS2013运行报错error C4996: 'scanf': This function or variable may be unsafe.
- 错误1error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead.
- Visual Studio 2013 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】
- 【VS2013】错误处理error C4996: 'fopen': This function or variable may be unsafe
- error C4996: 'scanf': This function or variable may be unsafe. 的解决方案
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- myeclipse开发工具中maven项目转换
- Linux ssh免密码登录
- enum枚举
- CTPN
- JS中的this都有什么作用?
- 解决VS2013中出现类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误
- 启动mysql时占用物理内存和虚拟内存过高问题
- BZOJ 3569 DZY Loves Chinese II(线性基)
- 169. Majority Element
- 1.1设计模式在Unity中应用—Behavioral Pattern— Chain of Responsibility Pattern 责任链模式
- 排序算法大合集
- linux下 bashrc与profile的区别
- Java Socket编程----通信是这样炼成的
- 中国电信携手机智云共建使能平台生态,推动NB-IoT/eMTC快速落地