I have the following problem. I try to check the format of the input value with the while loop. If the input is wrong, I want to get back and ask the user to give a new input. But this step is just skipped and it continues with the rest of the code. How can I fix it? Thanks in advance! P.S.: Credits is a double.
cout << "Enter amount of credits: ";
cin >> credits;
while(cin.fail()){
cout<<"Wrong input! Please enter your number again: ";
cin>> credits;
}