i try to limit the user key in integer at least 1 and not more than 8. pls help me..
Hi Check the code below, You will get some idea
void getpass(char passwd[])
{
int ch;
while(1)
{
printf("Enter your password : ");
u_int index=0;
while((ch=getch())!=13)
{
if(index < 8)
{
passwd[index]=ch;
}
index++;
putch('*');
}
if(index <2 || index > 8)//enter key
{
printf("\nPassword should be more than 1 and less than 9 charactes");
printf("\nPress any key to enter again...");
while(!_kbhit());
system("cls");
getch();
continue;
}
else
{
passwd[index]='\0';
break;
}
}
}
int main(int argc,char* argv[])
{
char passwd[9];
getpass(passwd);
printf("\npassword : %s\n",passwd);
return 0;
}