Why does this print out more than once?

I have this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
do{

   cout << "How many people are in the party? ";

   cin >> size;

   if(size > 0 && size <= 500)
   {
      correctSize = true;
   }
   else
   {
      cout << "Party size must be a whole number and greater than zero. Please      try again. " << endl;
      correctSize = false;
      cin.clear();
      cin.ignore();
      size = 0;
   }

}while(!correctSize);



It almost does what I need it to do. When I enter one letter or symbol it prints out the try again message. But when I enter two letters or symbols it prints the message out twice and so on. I have done different things with cin.clear and ignore but they haven't worked. Anyone know how I can fix this?
try cin.ignore(INT_MAX, '\n');
Thanks so much!!! Works great now
Topic archived. No new replies allowed.