私は運が悪いので、一日中これに取り組んできました。今は夜で、何をすべきかわかりません。私の課題は、ユーザーが入力した文の母音の数、空白の数、およびその他の文字の数を読み取ることです。空白に cin.get(ch) を使用する必要があることは知っていますが、方法がわかりません。また、文をファイルに出力する必要があります。私がこれまでに持っているものは次のとおりです。
//Get data from user
cout << "Enter your sentence on one line followed by a # to end it: " << endl;
while (cin >> noskipws >> character && character != '#')
{
character = static_cast<char>(toupper(character));
if (character == 'A' || character == 'E' || character == 'I' ||
character == 'O' || character == 'U')
{
vowelCount++;
isVowel = true;
}
if (isspace(character))
{
whiteSpace++;
}
else if (isVowel == true && isspace(character))
{
otherChars++;
}
outFile << character;
}
outFile << "vowelCount: " << vowelCount << endl;
outFile << "whiteSpace: " << whiteSpace << endl;
outFile << "otherchars: " << otherChars << endl;