Path: utzoo!utgpu!watmath!clyde!att!pacbell!ames!ncar!noao!arizona!naucse!wew From: wew@naucse.UUCP (Bill Wilson) Newsgroups: comp.sys.ibm.pc Subject: Re: Turboc floating scanf Message-ID: <1114@naucse.UUCP> Date: 11 Jan 89 16:46:21 GMT References: <370@atlas.tegra.UUCP> Organization: Northern Arizona University, Flagstaff, AZ Lines: 25 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. I give tcc a '-f' or '-f87' switch but I still get a > run-time error from scanf when it tries to read in a float. > 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 to convert it to a float var. For example: float x; char buf[12]; buf[0]=10; gets(buf); x=atof(buf); Please make sure to include the correct header files for these routines (refer to your manual). -- Bill Wilson (Bitnet: ucc2wew@nauvm) Northern AZ Univ Flagstaff, AZ 86011 {These views are mine and do not necessarily reflect those of my employer}