maths_fan wrote:
Don't you know the function that can make input without writing
charecters on the output (under UNIX). I mean something like, when you
write Password on Unix, you write and the charecters are not seen, but
there are written in the buffer. Does anyone know any Unix library
(maybe a function that can do it). There is no in stdio.h as I found
out :(
Someone posted this a while back:
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <string.h>
static struct termios stored_settings;
void echo_off(void)
{
struct termios new_settings;
tcgetattr(0,&stored_settings);
new_settings = stored_settings;
new_settings.c_lflag &= (~ECHO);
tcsetattr(0,TCSANOW,&new_settings);
return;
}
void echo_on(void)
{
tcsetattr(0,TCSANOW,&stored_settings);
return;
}
int main()
{
int ch;
int ph = '*';
echo_off();
while((ch = getchar()) != EOF)
putchar(ph);
echo_on();
return 0;
}
Unfortunately I don't recall who to credit for it.
Regards,
Ed.