Validation in a function

Im writting a program for my class, i pretty much have it figured out and is compiling properly, but when a character is imputed instead of a floating number, the program breaks. this is a the function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

double getSales(string division)
{
       double qSales=0;
       cout<<"\nWhat is the total quarterly sales of "<<division<<":$  ";
       cin>>qSales;
      
       while (qSales <= 0.00 || cin.fail())
       {
              
             cout << "Please Enter a Posive number." << endl;
             cout << "\nEnter another number: $  ";
             cin  >> qSales;
             
       }
       return qSales;       
}




how can i validate the input so that only numbers are inputed.
Look here:
http://www.cplusplus.com/forum/beginner/4566/#msg20182
(the final result is in the last post)
Topic archived. No new replies allowed.