从键盘输入一个字符串和一个字符,然后从该字符在字符串中首次出现的位置开始输出字符串中的字符,如果未找到该字符,则输出“Not Found”。
int match(char *s,char c){
int count=0;
while(*s!='\0')
if(*s==c)
return count;
else{
s++;
count++;
}
if(*s=='\0') return -1;
}
int main(void){
char ch,str[30],*p=NULL;
int pos,i;
scanf("%s",str);
getchar();
scanf("%c",&ch);
//if((pos=match(str,ch))!=-1){
if((pos=match(p=str,ch))!=-1){
for(i=pos;str[i]!='\0';i++)
printf("%c",str[i]);
printf("\n");
}else
printf("Not Found\n");
return 0;
}