原帖及讨论:http://bbs.woaidiannao.com/thread-228177-1-1.html
下面de代码:
#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 C4996de详细含义就系:'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.翻译过来,就系scanfde声明在VS2005中被认为系不安全de,让你使用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;
}