Originally Posted by Stoned_coder
OK, I'll explain it a little. GetInput takes a string to print to the console and returns an int that was entered. If there is a bad input then an error message is printed and the garbage removed from the stream so we can try recieve input again. When for instance cin is expecting an int but gets a char it goes into a failed state. All operations on a failed stream are null and void so first we must clear the error flags. This is what the cin.clear does. After that we can proceed to remove any garbage entered. The cin.ignore line basically says ignore as many chars as you can from the stream or up to the next newline char.This lets us proceed to getting an int from the user. Back in main we declare an int and initialise it with the return value of GetInput.
Need any further elaboration?
wow, that was certainly a lot of information in one paragraph! I got to digest all that slowly (i'm a bit slow, sorry). I think I understand what you coded...but I'm not really familiar with it...and my project is due in 2 days...so it's safer to stick to what I know right now....But your information is certainly great for future reference though (i'm sure more projects are coming my way...sighnnn).
anyway, I just posted my new code. Can you check that out and give me suggestions?