计算仅具有元音的子串的数量

我写了一段代码来查找给定子串的元音子串。但我需要帮助计算由此形成的子字符串吗?

码:

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

bool isVowel(char c) {
    return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
}

void substr(char str[], int low, int high)
{
    printf("%.*s \n\n", high-low+1, (str+low));
}

int main(int argc, const char *argv[]) {

    char str[] = "aeixae";

    int length = strlen(str);

    int start_index = 0, end_index = 0;

    for (int x=0; x<=length; x++) {
        if (x == length || !isVowel(str[x])) {
            end_index = x;
            substr(str, start_index, end_index - 1 );
            start_index = end_index + 1;
        }

    }
    return 0;
} 
评论