I am doing a project in C program which requires to type in password in Unix terminal. Does anybody know how to shade or not output any words typed by user in the terminal?
I use the function scan() to read typing from user. Thanks in advance.
I am doing a project in C program which requires to type in password in Unix terminal. Does anybody know how to shade or not output any words typed by user in the terminal?
I use the function scan() to read typing from user. Thanks in advance.
sorry Driver, i really can't figure out the solution for my question with the code below that you posted. Would you please explain more with a simple code to do that? Thanks.
#include <termios.h>
#include <stdio.h>
int
getch(void) {
struct termios old;
struct termios new;
int rc;
if (tcgetattr(0, &old) == -1) {
return -1;
}
new = old;
new.c_lflag &= ~(ICANON | ECHO);
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
if (tcsetattr(0, TCSANOW, &new) == -1) {
return -1;
}
rc = getchar();
(void) tcsetattr(0, TCSANOW, &old);
return rc;
}
Driver,
thanks very much for help. I have find the solution. Your code works.