//计算两个数的和
int main()
{
int num1 = 0;
int num2 = 0;
int num=0;
scanf("%d%d", &num1, &num2);//取地址符&
num = num1 + num2;
printf("%d\n", num);
return 0;
}
!!!报错:严重性?? ?代码?? ?说明?? ?项目?? ?文件?? ?行?? ?禁止显示状态 错误?? ?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.?? ? test1.13?? ?C:\Users\***\source\repos\test1.13\test1.13\源.cpp?? ?8?? ?
原因:
scanf是C语言提供的,scanf_s不是标准C语言提供的,VS编译器提供的 为了用scanf让代码具有可移植性,所以源文件的第一行加上#define _CRT_SECURE_NO_WARNINGS 1让警告失效
解决办法:
F:\**\Visual Studio\Common7\IDE\VC\vcprojectitemsopenfolder 用Notepad++打开newc++file.cpp进行修改
|