Based on the comments to other answers, you want to check that someone has entered a four-digit string. The easy way to do this is to use an array of char
to store the input, and to use strlen
to get the length of the input string:
#include <stdio.h>
#include <string.h>
...
char input[5]; // extra space for string terminator
printf( "Enter password: " );
if ( scanf( "%4s", input ) != 1 ) // read no more than four characters
{
// error on input
}
else if ( strlen( input ) < 4 )
{
// password too short
}
else
{
// check password value
}