Basically I would like to ensure that a valid numeric number is being input.
Now If I were to input a valid number, the program will hang.
If I were to input a invalid number, the program will go into a crazy loop.
umeric number (0-9)Invalid numeric numberPlease enter a numeric number (0-9)Inva
lid numeric numberPlease enter a numeric number (0-9)Invalid numeric numberPleas
First, awful use of exceptions. If you are going to handle the error just below, use an if...else structure.
Line 8 will never be executed (and it shouldn't return true)
You are trying to read the data twice (when you call your function and inside the while) cin.rdbuf()->in_avail() This is returning 0.