samedi 28 mars 2015

How to keep looping until non-integer is entered


I have this program where I am trying to keep looping until something that is entered is a non-integer. No matter if I enter a non-integer or an integer the program still breaks and end. Please help



int data;
do
{
cout<<"enter data: ";
cin>>data;
cout<< "yes"<<endl;
return data;
} while(cin.good());



Aucun commentaire:

Enregistrer un commentaire