why isn't this working

This is a discussion on why isn't this working within the C++ Programming forums, part of the General Programming Boards category; why isn't my program working??
char ch;
int countspace=0;
cout << "Please enter a line of text, ";
cout << ...

First, counting spaces isn't safe unless you know what the format of the input will be like, what if I entered a line with each word separated by two spaces? To be safe and simple here is what you do, ask the user to enter a series of words to start, they really should know what to do or the program won't be useful. Use cin.get to read the first character of the input and test if it's a vowel, if it is then change the case to upper.

Go into a loop to check for a newline and test for a space, if it's a space then print one space and loop until you don't have a space, test that for vowel and if it is change the case. If it isn't just print the character. If it's not a space at all, print the character and get a new one, at the end print a newline and you're done.

Originally posted by Prelude
First, counting spaces isn't safe unless you know what the format of the input will be like, what if I entered a line with each word separated by two spaces? To be safe and simple here is what you do, ask the user to enter a series of words to start, they really should know what to do or the program won't be useful. Use cin.get to read the first character of the input and test if it's a vowel, if it is then change the case to upper.

Go into a loop to check for a newline and test for a space, if it's a space then print one space and loop until you don't have a space, test that for vowel and if it is change the case. If it isn't just print the character. If it's not a space at all, print the character and get a new one, at the end print a newline and you're done.