gets()函数会被屏蔽吗?
/*程序功能:输入一个日期,显示是本年的第几天?并且可以连续循环实现功能!
问题:为何疑问处(见注释)使用一个gets函数无法实现?
*/
#include<stdio.h>
#include<windows.h>
#include<string.h>
struct
{
int year;
int month;
int day;
}date;
int main()
{
int days;
char b[5]="stop";
char a[5];
while(1)
{
printf("请输入操作指令(stop or action)\n");
gets(a); /*这里是疑问处*/
/* 在加上一个gets()函数就行了,为什么??*/
if(strcmp(a,b)==0)
{printf("程序结束!!\n");break;}
printf("input year,monht,day:");
scanf("%d,%d,%d",&date.year,&date.month,&date.day);
switch(date.month)
{
case 1:days=date.day; break;
case 2:days=date.day+31; break;
case 3:days=date.day+59; break;
case 4:days=date.day+90; break;
case 5:days=date.day+120; break;
case 6:days=date.day+151; break;
case 7:days=date.day+181; break;
case 8:days=date.day+212; break;
case 9:days=date.day+243; break;
case 10:days=date.day+273; break;
case 11:days=date.day+304; break;
case 12:days=date.day+334; break;
}
if((date.year%4==0)&&(date.year%100!=0)||(date.year%400==0)&&(date.month>=3))
{
days+=1;
}
printf("您所输入的日期属于%d的第%d天\n",date.year,days);
}
system ("pause");
return 0;
}