首页 > 代码库 > VS2012 [warning C4996]: 'sprintf': This function or variable may be unsafe.

VS2012 [warning C4996]: 'sprintf': This function or variable may be unsafe.

使用VS2012编译时,会出现以下警告:

warning C4996: ‘sprintf‘: This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.如图:




c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(371) : 参见“sprintf”的声明


解决办法:


工程->属性->配置属性->C/C++->预处理器->预处理器定义

添加以下定义就可以解决:

_CRT_SECURE_NO_DEPRECATE
_SCL_SECURE_NO_DEPRECATE


VS2012 [warning C4996]: 'sprintf': This function or variable may be unsafe.