Code:
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
static struct termios oldt;
void restore_terminal_settings(void)
{
tcsetattr(0, TCSANOW, &oldt); /* Apply saved settings */
}
void disable_echo(void)
{
struct termios newt;
tcgetattr(0, &oldt); /* Save terminal settings */
newt = oldt; /* Init new settings */
newt.c_lflag &= ~ECHO; /* Change settings */
tcsetattr(0, TCSANOW, &newt); /* Apply settings */
}
int main()
{
char myPass[100];
printf("Input password: ");
disable_echo();
scanf("%s", myPass);
restore_terminal_settings();
printf("\n");
return 0;
}
For an explanation about how it works see this thread:
http://www.linuxquestions.org/questi...hreadid=208803