program skipping input

the program executes properly the first time
but if the user any key to continue it skips the input and displays #1,#2, and #3 without asking the user to input another sentence
i need help solving this
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
40
41
#include <iostream>	
#include <cstring>

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

}
Your cin>> is probably leaving an enter key press in the buffer, so the next time you try to read a string, it sees that enter key as the end of the user's input.
thanks that makes sense
theres one more problem i have
i dont know how to do the word count
can someone help
u define a word : some character that eather have nothing, or have a spice befor and after them.
(example this is an end,And this a begin. in this case u read end,And as one word)

so u could make a function that counts 1 for every set of characters wich have a space before and after. and define the special cases, start of the senence and end of it.

hope it helps
Topic archived. No new replies allowed.