c语言,strchr()|c语言,strchr(),查找字符串中第一次字符出现的位置

int main(void)
{
char string[15];
char *ptr, c = 's';
strcpy(string, "This is a string");
ptr = strchr(string, c);

if (ptr)
printf("The character %c is at position: %d\n", c, ptr-string);
else
printf("The character was not found\n");
return 0;
}
【c语言,strchr()|c语言,strchr(),查找字符串中第一次字符出现的位置】转载于:https://www.cnblogs.com/wsq724439564/p/3258176.html

    推荐阅读