Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!sun-barr!newstop!sun!imagen!qmsseq!pipkins From: pipkins@qmsseq.imagen.com (Jeff Pipkins) Newsgroups: comp.sys.ibm.pc Subject: Re: MS-DOS call to read without echo Message-ID: <109@qmsseq.imagen.com> Date: 8 Feb 90 19:00:51 GMT References: <1036@spocm2.UUCP> Reply-To: pipkins@qmsseq.UUCP (Jeff Pipkins) Organization: QMS Inc., Mobile, Alabama Lines: 27 In article <1036@spocm2.UUCP> lhv@spocm2.UUCP (Leo Vermeulen) writes: > >I have the following problem: I'm trying to write a C-program, using >Microsoft-C 5.1, that reads a character string from the keyboard and >assigns it to an character array. Since this string is supposed to be >a password, I do not want it echoed to the display. As others have mentioned in reply, the getch() function provided with both MSC and Turdo C is probably the easiest solution. MSC provides a library of console routines when you include conio.h. I was not happy with these for two reasons. First, if a user redirects stdin and/or stdout when invoking your program, some of the MSC conio routines are affected and others are not. For example, the cprintf() function writes to stdout just like printf() does! This has to be considered a bug -- why else would there be two different functions?! The other problem is that the output of the kbhit() function is not completely defined in the documentation and could be more useful if it were more complete. Yes, kbhit() is inherently PC-specific and nonportable. I few years ago, circa MSC 3.x, I rewrote the conio library to solve these problems. It is now in the public domain and works for both MSC and Turdo C. I submitted it to the C User's Group, and someone seems to have uploaded it to SIMTEL as PD1:CONIO.ARC. It is written in ASM and includes source. Standard disclaimers and all that.