例如定义 char str[]="abcdefg.............."
现在想要找到STR里面有没有字符“z” ,如果有字符”z“则返回值为1 没有为零
#include <stdio.h>
int FindChrInStr(char *);
int main()
{
char str1[] ="abcde";
char str2[] ="wxyzabc";
printf("%d\n",FindChrInStr(str1));
printf("%d\n",FindChrInStr(str2));
}
int FindChrInStr(char *s)
{
while(*s)
{
if('z'==*s)
{
break;
}
s++;
}
if(*s)
{
return 1;
}
else
{
return 0;
}
}