The standard way to clear cin is
Code:
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
You have to #include <limits> and <ios> for numeric_limits and streamsize. This should work well if you are using operator>> to read in your numbers, since it will not cause any issues on valid input either.
Another option is to use getline to read into a string, then place the contents of that string into a stringstream and get the numbers out of there. Anything leftover in the stringstream will just not be processed. This has the added benefit of keeping cin from entering a fail state if the user enters bad data (like non-numeric characters), since getline accepts all characters. However, you can also just add similar code to handle that situation directly with cin.