错误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.
/* 错误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. */
#include<stdio.h>
int main()
{
char buf[1024] = " ";
sprintf(buf, "abc");
printf("buf=%s\n", buf);
return 0;
}
解决方法:
方法一:(1)#define _CRT_SECURE_NO_WARNINGS //这个宏定义最好要放到.c文件的第一行
方法二:(2)#pragma warning(disable:4996) //或者使用这个