练习7-10 查找指定字符 (15分)
代码:
#include <stdio.h>
#include <string.h>
int main()
{
char c, str[81];
scanf("%c", &c);
getchar();
gets(str);
int i = 0, index = -1, length = strlen(str);
for (i = 0; i < length; i++)
{
if (str[i] == c) index = i;
}
if (index == -1) printf("Not Found");
else printf("index = %d", index);
return 0;
}