Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n cin.ignore()
- what if you did
- cin.ignore(5, '\n');
- and the user entered
- abcdefghij
- that would be over 5. But this would only ignore 5 characters
- so the programmer used
- cin.ignore(10, '\n');
- and the user entered
- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
- and it still doesn't cover what the user entered
- so the programmer used
- cin.ignore(20,'\n');
- and the user entered
- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
- still not enough
- so my question is, if you never can predict what the user is going to enter,
- how do you even come close to picking the numeric that is needed within ignore?
- ignore will work in some case and fail in other
- why would you pick code that could fail in some cases?
- not good coding?
- you need code that will work exactly as you want in all cases
- and that would NOT be with ignore
- so what will work in all cases?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement