Hi. I am writing a mastermind console game. Everything is working except for the fact that I can not limit input. eg:
1 2 3
cin << x0 << x1 << x2 << x3;
// blah blah blah.
my problem is, that when i type more than for characters, the remaining characters are stored in the buffer and get execute by the comparison code simultaneously after each other.
lets say the max input is 4 chars.
and each turn the number of chars in the correct chars in the correct place and the number of correct chars in the wrong place is returned.
so writing 12345
will result in: 3 in correct place, 0 in wrong place
0 in correct place, 1 in wrong place
While the syntax cin >> var1 >> var2 >> var3 ... is simple and elegant, its lack of error handling makes it almost useless for any non-trivial application.