C ++如何将char数组的每三个字母变成大写字母?

C++ How do you make every third letter of a char array into an uppercase letter?

目前我已经想出如何将每个元音变成 '!' 并且它确实有效。我为此使用了 bool isVowel() 函数。

现在我想每隔三个字母大写一次。我的数组是 char aPhrase[15] = "strongpassword":

while (aPhrase[i])
{
c=aPhrase[i];
putchar(toupper(c));
i+=3;
}

这让我 SOPSRR 而不是 Str!ngP!sSw!Rd

while (aPhrase[i]) {
    c = aPhrase[i];
    if (isVowel(c)) 
        c = '!';
    else if ((i % 3) == 0)
        c = toupper(c);
    putchar(c);
    ++i;
}