#include <stdio.h> #include <minmax.h> int main( ) { int a,b,c; scanf("%d,%d",&a,&b); c=max(a,b); printf("max=%d",c); return 0; } |
使用vs2005编译时会遇到这样一个warning: warning C4996: 'scanf' was declared deprecated
其实 warning C4996的详细含义就是:'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.翻译过来,就是scanf的声明在VS2005中被认为是不安全的,让你使用scanf_S来代替。
知道了原因,那解决就方便了,只要在#include <stdio.h>前面添加#define _CRT_SECURE_NO_DEPRECATE 或者 scanf函数修改为scanf_s即可。具体如下:
#define _CRT_SECURE_NO_DEPRECATE #include <stdio.h> #include <minmax.h> int main( ) { int a,b,c; scanf("%d,%d",&a,&b); c=max(a,b); printf("max=%d",c); return 0; } |
#include <stdio.h> #include <minmax.h> int main( ) { int a,b,c; scanf_s("%d,%d",&a,&b); c=max(a,b); printf("max=%d",c); return 0; } |