thanks, but there is still one problem.
for example, I want the user to enter a medical fees and I use a program like this
"
while (true) {
cout << "Please enter a valid number: ";
getline(cin, input);
// This code converts from string to number safely.
stringstream myStream(input);
if (myStream >> myNumber)
break;
cout << "Invalid number, please try again" << endl;
}
cout << "You entered: " << myNumber << endl << endl;
"
if I enter something like "1234zzz"
the stringstream will take "1234" only.
so how can i solve this?