Erick
2010-04-26 16:59:13 UTC
after the user inputs a key to continue it displays
#1,#2, AND #3 together and asks the user to input a key to continue
it skips the first cout
also, how do i do the charecter count without the spaces, and the word count?
*******************************************
#include
#include
int main ( )
{
char choice = ' ';
std::string sentence = " ";
do {
//#1
std::cout << "Please enter your sentence, ending with a period(.): " << std::flush;
std::getline (std::cin, sentence);
if (sentence.length() > 100 || sentence.substr(sentence.length() - 1, 1) != ".")
{
std::cout << "Error missing '.' or exceeded number of characters" << std::endl;
}
else
{
//#2
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: " << sentence.find('a', 0) << std::endl;
}
//#3
std::cout << "Press any key to continue...('s' to stop): " << std::flush;
std::cin >> choice;
} while (choice != 's');
return (0);//end
}