Path: utzoo!attcan!uunet!lll-winken!ames!pasteur!ucbvax!ucsfcgl!cgl.ucsf.edu!kneller From: kneller@cgl.ucsf.edu (Don Kneller) Newsgroups: comp.sys.ibm.pc Subject: Re: Turboc floating scanf Message-ID: <11317@cgl.ucsf.EDU> Date: 12 Jan 89 19:25:46 GMT References: <370@atlas.tegra.UUCP> <1114@naucse.UUCP> Sender: daemon@cgl.ucsf.edu Reply-To: kneller@socrates.ucsf.edu.UUCP (Don Kneller) Organization: UCSF Computer Graphics Lab Lines: 24 In article <1114@naucse.UUCP> wew@naucse.UUCP (Bill Wilson) writes: >From article <370@atlas.tegra.UUCP>, by vail@tegra.UUCP (Johnathan Vail): >> >> I am using the "latest" version of TurboC and am trying to use scanf >> to read floats. >> >scanf is one of the worst C functions. I would suggest that you create >a character buffer, read into it and use the atof function: > float x; > char buf[12]; > > gets(buf); > x=atof(buf); gets() is also a terrible function to use. It is too easy to overwrite memory because gets() does not know how long the input buffer is. It is much safer to use fgets(). - don ----- Don Kneller UUCP: ...ucbvax!ucsfcgl!kneller INTERNET: kneller@cgl.ucsf.edu BITNET: kneller@ucsfcgl.BITNET