#include<stdio.h>
#include<string.h>
char* find(char* a, char b)
{
int flag = 0;
while (*a)
{
if (*a == b)
{
flag = 1;
break;
}
else
a++;
}
return flag;
}
int main()
{
char* c;
char e[20];
char d='a';
int n;
printf("Type down the character you want to find in a string:(q tot quit)");
while (d != 'q')
{
c = fgets(e, 20, stdin);
d = getchar();
n = find(c, d);
if (n)
puts("The character is in the string.");
else
puts("The character is not in the string.");
while (d != '\n')
{
d = getchar();
continue;
}
printf("Next string and character?:(q to quit)");
d = getchar();
}
printf("Bye");
return 0;
}
c primer plus第十一章编程题6
最新推荐文章于 2024-08-07 17:33:57 发布