找出一个字符串中所有的元音字母

int main()
{
    char sentence[] = "Wangye is a handsome boy!";
    char Vowels[] = "aeiou";
    char* pch = NULL;
    printf("Vowels in '%s': ", sentence);

    pch = strpbrk(sentence, Vowels);//这里用了strpbrk函数

    while (pch != NULL)
    {
        printf("%c ", *pch);
        pch = strpbrk(pch + 1, Vowels);
    }
    printf("\n");

    system("pause");
    return 0;
}

找出一个字符串中所有的元音字母_第1张图片

strpbrk
函数原型:char* strpbrk( const char*, const char* );

注释:Returns a pointer to the first occurrence in str1 of any of the characters that are part of str2, or a null pointer if there are no matches.

返回第一个字符串中第一个出现在第二个字符串中的字符的地址

你可能感兴趣的:(C练习题)