H
hem
Hi,
I have the following small program which read password from user after
echoing off. But the problem is, it is freezing for some time (not sure
about the duration) before going to the next statement and I have to
press "enter" multiple times (maximum 4, it is not consistent though).
I am trying it on a hp-ux machine with aCC compiler.
Any pointers/help would be greatly appreciated.
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include<string.h>
int main(int argc, char *argv[])
{
struct termios oldt,
newt;
char ch;
char userpasswd[50];
printf("enter password:");
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
gets(userpasswd);
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
printf("\nPassword enetered %s\n", userpasswd);
return 0;
}
Thanks,
Reddy
I have the following small program which read password from user after
echoing off. But the problem is, it is freezing for some time (not sure
about the duration) before going to the next statement and I have to
press "enter" multiple times (maximum 4, it is not consistent though).
I am trying it on a hp-ux machine with aCC compiler.
Any pointers/help would be greatly appreciated.
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include<string.h>
int main(int argc, char *argv[])
{
struct termios oldt,
newt;
char ch;
char userpasswd[50];
printf("enter password:");
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
gets(userpasswd);
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
printf("\nPassword enetered %s\n", userpasswd);
return 0;
}
Thanks,
Reddy