Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!udel!new From: new@udel.edu (Darren New) Newsgroups: comp.sys.amiga Subject: Re: Lattice C Message-ID: <6484@nigel.udel.EDU> Date: 19 Dec 89 17:59:33 GMT References: <6035@mentor.cc.purdue.edu> Sender: usenet@udel.EDU Reply-To: new@udel.edu (Darren New) Organization: University of Delaware Lines: 16 In article <6035@mentor.cc.purdue.edu> jeo@mentor.cc.purdue.edu (Richard Napier) writes: > scanf("\n%c",&chr1); >According to a C book I have the \n before the %c in the scanf() should >make the scanf ignore the \n that the previous scanf leaves behind. I >tried this onthe UNIX system at Purdue University, and it worked fine. >I then tried it on the Amiga, compiled it with Lattice C, and it doesn't >work. The \n before the %c in the second scanf command is ignored. I had this same problem. The problem is that ANSI differs from Unix in this respect. Also, the Lattice manual documents it for the wrong version. Seems they forgot to change it when upgrading the library to ANSI. In reality ALL WHITESPACE IN A SCANF SPECIFICATION IS IGNORED! Your easiest solution around this bug-like feature (:-) is to simply scanf("%*c%c",&chr1) or {getchar(); scanf("%c", &chr1);}. (Check my syntax on that... I don't do stdio very much). Good luck, and may your manuals always be up to date. -- Darren