- 论坛徽章:
- 0
|
int main(int argc, char *argv[])
{
struct termios ts,ots;
char passbuf[1024],passbuf1[1024];
unsigned char *epwd;
int i;
tcgetattr(STDIN_FILENO,&ts);
ots = ts;
ts.c_lflag &= ~ECHO;
ts.c_lflag |= ECHONL;
tcsetattr(STDIN_FILENO,TCSAFLUSH,&ts);
if(ts.c_lflag & ECHO){
fprintf(stderr,"Failed to turn off echo \n");
tcsetattr(STDIN_FILENO,TCSANOW,&ots);
exit(1);
}
printf("Enter password:");
fflush(stdout);
fgets(passbuf,1024,stdin);
printf("Re-type password:");
fflush(stdout);
fgets(passbuf1,1024,stdin);
if(strcmp(passbuf,passbuf1) != 0){
fprintf(stderr,"password not same \n");
exit(1);
}
printf("%s",passbuf);
tcsetattr(STDIN_FILENO,TCSAFLUSH,&ots);
return 0;
} |
|