解释一下函数是什么意思TwT
//输入命令
int input_cmd(char *str,int len){
int count = 0;
char c;
while(count < len && (c = getchar())!= '\n'){
str[count++] = c;
}
str[count] = '\0';
if(count > 0){
if(str[0] >= 'A' && str[0] <= 'Q'){
str[0] = str[0] - 'A' + 'a';
}
}
//printf("%s,%d",str,count);//测试
return count;
}
void add(Event **list){
char cmd[201];
int year,month,day,pos,count;
year = 2022;
printf("Which day you want to add event?(day-month-year)\n");
if( 3 > input_cmd(cmd,200)){
printf("Please enter right date(day-month-year).\n");
return;
}
pos = 0;
day = atoi(cmd);
if(day > 9){
pos += 3;
}
else{
pos +=2;
}
month = atoi(cmd+pos);
if(month > 9){
pos += 3;
}
else{
pos +=2;
}
if(month <= 0 || month > 12 || year !=2022 || day <= 0 || day > 31){
printf("Please enter right date.\n");
return;
}
count = get_events(*list,year,month,day);
if(count >= 5){
printf("The events is %d.\n",count);
return;
}
get_monthe(month,cmd);
Event *e = (Event*)malloc(sizeof(Event));
e->year = year;
e->month = month;
e->day = day;
e->next = NULL;
printf("Input event:");
scanf("%s",e->content);
add_event(list,e);
printf("successful!, %d %s %d has add event:%s.\n",day,cmd,year,e->content);
}