In my program, I have a 4 digit field that the user enters data.
How can I code a way to recognize and reject the entry if 1,2,3 or 5 or more digits are entered into the field?
In my program, I have a 4 digit field that the user enters data.
How can I code a way to recognize and reject the entry if 1,2,3 or 5 or more digits are entered into the field?
If digits is not 4 when you're done, handle invalid input.Code:while ( val != 0 ) digits++, val /= 10;
-Prelude
My best code is written with the delete key.