这有问题吗?
#include <stdio.h>#include <string.h>
#define MAXS 80
int getindex( char *s );
int main()
{
int n;
char s[MAXS];
scanf("%s", s);
n = getindex(s);
if ( n==-1 ) printf("wrong input!\n");
else printf("%d\n", n);
return 0;
}
int getindex(char *s)
{
const char *p[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int i,IF=0;
for(i=0;i<7;i++)
{
if(strcmp(*s,p[i])==0)
{
return i;
break;
}
printf("%s\n",p[i]);
}
if(IF==0)
return -1;
}
//26 26 C:\Users\ASUS\Documents\未命名11.cpp [Error] invalid conversion from 'char' to 'const char*' [-fpermissive]