>but what about the (num!=8) ? is this an ascii ?
No. This is a straight numeric test. However, the coding is incorrect. Notice how num isn't set to any value before it comes to this statement? That is wrong, because num could be any value. I don't think you need the if statement anyway.
Theres another problem, as well.
>while ((pass[num] = getch()) != 13)
This will keeping adding characters to the array as the user enters them. At some point, the array size will be exceeded (pass is only 9 bytes), and you will start writing over memory that is not yours! Bad mistake, I'm afraid! It also doesn't allow for the user trying to delete a character (backspace is just another key entry as far as getch() is concerned).
Here's some code I posted somewhere else. Have a look through and see if you understand it OK. Don't use it if you don't want to, I only provide it as an example.
Code:
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#define PASSLEN 10
int main(void)
{
int ch, i;
char password[PASSLEN + 1];
printf("Enter your password: ");
i = 0;
while ((ch = getch()) != '\r' && i < PASSLEN)
{
if (ch == '\b')
{ /* Handle backspace */
if (i > 0)
{
i--;
printf("\b \b");
}
password[i] = '\0';
}
else if (isalnum(ch))
{ /* Only characters and numbers considered to be part of the password */
password[i] = ch;
putchar('*');
i++;
}
}
password[i] = '\0';
printf("\nThank you, you entered: %s\n", password);
return(0);
}
>BTW, where are u all from?
England.