program skips inpuit string
the program executes fine the first time, then it displays the first cout, the else statement and the last cout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <iostream>
#include <cstring>
int main ( )
{
char choice = ' ';
std::string sentence = " ";
do {
std::cout << "Please enter your sentence, ending with a period(.): " << std::flush;
std::getline (std::cin, sentence);
if (sentence.length() > 10)
{
std::cout << "Too long" << std::endl;
}
else
{
std::cout << "Your sentence has... " << std::endl;
std::cout << "Words: " << std::endl;
std::cout << "Characters (no spaces): " << std::endl;
std::cout << "Characters (with spaces): " << sentence.length() << std::endl;
std::cout << "The letter 'a'|'A' count: " << std::endl;
}
std::cout << "Press any key to continue...('s' to stop): " << std::flush;
std::cin >> choice;
} while (choice != 's');
return (0);//end
}
| |
Please don't cross/double post.
Topic archived. No new replies allowed.