error C4996: ‘scanf’: This function or variable may be unsafe.Visual Studio系列编译器使用scanf函数报错
在使用Visual Studio 系列编译器使用scanf函数是,是否需到下面这句话呢?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.刚开始使用时,没有作为对编译器限制时,答案是肯定的。
在Visual Studio系列编译器中,认为scanf函数是不安全的,即使你引入了头文件,但是编译器还是认为它是不安全的。下面我将为大家带来三种解决方法:
方法一:
在.c文件中的头部加入#pragma warning(disable:4996)
方法二:
在.c文件中的头部加入宏#define _CRT_SECURE_NO_WARNINGS 10//10可以替换为别的整数
方法三:
按照编译器的要求使用scanf_s代替scanf
转载请注明:有客帮 » error C4996: ‘scanf’: This function or variable may be unsafe