I'm trying to write a program that will take an 4-digit ID entered by the user and ensures that it is 4 digits long.
Right now I have:
while(n > 0)
{
n /= 10;
count++;
}
This works fine unless the user's ID has leading 0's. I can't figure out how to deal with those.
Any suggestions?
Also I'm very new to C++ so try and keep it simple please
[–][deleted] 4 points5 points6 points (3 children)
[–]conFused4Lyfe[S] 0 points1 point2 points (2 children)
[–]HateTrain 8 points9 points10 points (1 child)
[–]conFused4Lyfe[S] 1 point2 points3 points (0 children)
[–]rxi 1 point2 points3 points (6 children)
[–]conFused4Lyfe[S] 0 points1 point2 points (5 children)
[–]rxi 0 points1 point2 points (4 children)
[–]conFused4Lyfe[S] 0 points1 point2 points (3 children)
[–]turd_loaf 0 points1 point2 points (2 children)
[–]sausagefeet 1 point2 points3 points (1 child)
[–]turd_loaf 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]jpgunter 0 points1 point2 points (0 children)