From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: F6 and fgets loop goes mad Date: Sun, 08 Mar 1998 12:48:41 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 36 Message-ID: <3502D9F9.46FC@cs.com> References: <34FFB2DB DOT 4B11 AT sainet DOT net> NNTP-Posting-Host: ppp229.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk shifter wrote: > > I have a password program that works fine until I press F6 then ENTER > and it goes into a wild loop ignoring fgets. > Is this a bug in DJGPP? F6 is an extended key and will cause stdio routines to barf if you don't trap it correctly. Extended keys return two key values: ASCII 0 to signal an extended key, followed by the code for the key itself. Most compiler manuals and some textbooks give listings of the extended keys. I just ran a quick test and it appears that stdio routines interpret some extended keys like F6 as EOF characters. This could be the cause of your problems. It is absolutely not a good idea to use stdio routines in programs that depend on robust keyboard input. This applies no matter what compiler you use. The functions in are much better at trapping extended keys; at least you get the opportunity to detect them and respond appropriately. The conio functions also make it possible to do things like not echo the keystrokes when entering a password. For really robust work, use and the getkey() function, which returns both normal and extended keystrokes as special codes whose symbolic names are defined in . I suggest you look them up. Hope this helps! -- --------------------------------------------------------------------- | John M. Aldrich | A singer in a smoky room / Smell of | | aka Fighteer I | wine and cheap perfume / For a smile | | mailto:fighteer AT cs DOT com | they can share the night / It goes | | http://www.cs.com/fighteer | on and on and on... | ---------------------------------------------------------------------