void main()
{
int tmp;
printf("请输入需要查找的数值\n");
scanf("%d",&tmp);
system("pause");
}
大家讲道理2017-04-17 12:02:20
c:code二分查找二分查找source.cpp(11): 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.
1> c:program files (x86)microsoft visual studio 12.0vcincludestdio.h(283) : see declaration of 'scanf'
巴扎黑2017-04-17 12:02:20
If you can speak English, you should be able to understand the compiler prompts. Starting from a certain version of VS, most of the input and output functions in the original stdio, such as printf, are marked as unsafe. It used to be a warning. It is possible It's because you turned on -Wall, or it may be that the error is forced directly now. Just switch to a safe version like printf_s. The usage is basically similar. For details, you can check msdn
ringa_lee2017-04-17 12:02:20
What is written upstairs is not the point. The point is that C++11’s strict overflow check solution for strings: you just need to replace scanf with scanf_s
伊谢尔伦2017-04-17 12:02:20
VS2013 has mandatory security checks. scanf is an unsafe function. It is recommended to use scanf_s in the c+11 standard. If you don’t want to use it, you can #define _CRT_SECURE_NO_WARNINGS at the beginning of the header to skip the security check!