I am teaching myself C++. I am writing a lotto program to read in dates and numbers and update a file. This code snippet:
int numberset[6];
cout<<endl<<"now, enter the 6 numbers. Hit return between each number:";
for(int i=0;i!=6;i++){
cin>>numberset[i];
while(numberset[i]<1 || numberset[i]>53){
cout<<"the number is not a valid, lotto number! please re-enter: ";
cin>>numberset[i];
}
works completely as expected when the user inputs an integer, any integer. If a float is entered, the loop becomes infinite. I attempted to correct by adding this line:
cin.clear(); right before the second attempt to cin>numberset ;
Which did not help at all. I guess something is wrong with the istream, but i dont know what it is, or how to fix it. I do appreciate any help.