By not using scanf() . You need to read the entire input as a string and validate each character. If it validates properly, convert the input to an integer.
Look at fgets()
Actually, using C++ you want getline()
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
I've searched up fgets() , and on most of the websites I read that this is an un-save function which can return faulty values.
Whatnezachem said...
Also getline() is a member of iostream, which I planned "not" to use because of the weird syntax.
What's weird about it?There aren't any other ways to do this? It's just weird for me since I always worked with language which where type-safe.
Yeah, but thesyntax is even weirder -- and harder...
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944