I'm trying to make a program that displays the word length of the inputted word.
Here is what it would look like:
Word Length
Come 4
Again 5
Hair 4
The 3
Basically, once the user inputs the word, the amount of syllables comes right after when you press enter. Unfortunately, the cin code actually takes the enter key into account when you press enter so instead of being in the same line, the length output becomes a new line.
I'm trying to find a way to either remove that new line that cin makes or ignore it, at least so I could achieve the desired output.
Thanks!
string words[4];
int wlength[4];
cout <<"word length" <<endl;
cout << endl;
cout << "";
cin >> words[0];
wlength[0] = words[0].length();
cout << wlength[0] <<endl;
cout << "";
cin >> words[1];
wlength[1] = words[1].length();
cout << wlength[1] << endl;
cout << "";
cin >> words[2];
wlength[2] = words[2].length();
cout << wlength[2] << endl;
cout << "";
cin >> words[3];
wlength[3] = words[3].length();
cout << wlength[3] << endl;
Actual output:
Word Length
Come
4
Again
5
Hair
4
The
3