错误处理error C4996: 'fopen': This function or variable may be unsaf

编译出错信息:错误    1    error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.  

首先我们分析错误提示,这个方法或者变量可能是不安全的,考虑使用fopen_s来代替。若要禁用安全警告,看在线帮助的具体细节。

方法1:我们用fopen_s来代替原来的方法fopen

方法2:在c++预处理器中添加_CRT_SECURE_NO_WARNINGS的定义。

第二种方法我们可以这么做:

(1)点击项目--》属性--》c/c++--》预处理器--》预处理定义--》点击下拉按钮


(2)添加_CRT_SECURE_NO_WARNINGS,点击确定就ok了。



猜你喜欢

转载自blog.csdn.net/lbc2100/article/details/79884053