If it is an integer variable, checking for
< 1000
and for not being negative or zero depending on your requirements is enough .
Numeric types in programming languages do not have leading zeroes. But string representations might have. If you have a string representing a number and that must contain leading zeroes, you can use the
strtol - C++ Reference[
^] function:
while (*szInput && !isdigit(*szInput))
++szInput;
char *stop;
long num = strtol(szInput, &stop, 10);
if (stop - szInput == 3)
{
}