From: "Dan, Ho-Jin" Newsgroups: comp.os.msdos.djgpp Subject: Re: Getch() in UNIX Date: Thu, 07 May 1998 09:29:54 +0000 Organization: KAIST Lines: 42 Message-ID: <35517F12.2ECAC739@cais.kaist.ac.kr> References: <354EE6B2 DOT 41C6 AT cc DOT hut DOT fi> NNTP-Posting-Host: casad4.kaist.ac.kr Mime-Version: 1.0 Content-Type: text/plain; charset=EUC-KR Content-Transfer-Encoding: 8bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk #include #include int getch() { struct termio o, n; char c; ioctl(0, TCGETA, &o); ioctl(0, TCGETA, &n); n.c_lflag &= ~(ICANON | ECHO); n.c_cc[VMIN] = 1; n.c_cc[VTIME]= 0; ioctl(0, TCSETA, &n); while(read(0, &c, 1) <= 0); ioctl(0, TCSETA, &o); return (int)c; } Ville Lundberg wrote: > I'm putting up a server and writing a program to it that asks for an > password. I first wrote the program at home with DJGPP to DOS, and > thought it would compile in UNIX. But it didn't, and I found out that it > was because UNIX hasn't GETCH() as DOS does. > So could anyone show me how to write that little piece of code that ask > for the password WITHOUT echoing it to screen? I mean, a password that > anyone can see by lookin over the shoulder is quite useless, isn't it? > ;-) Thanks, > --Ville > > =-----= > 51) Pelimiehet ei tee virheitä. > Ville Lundberg vlundber AT cc DOT hut DOT fi www.hut.fi/~vlundber/pelimiehet > -----=