Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.lang.c Subject: Re: Reading floating point numbers Message-ID: <933@mwtech.UUCP> Date: 24 Sep 90 12:16:39 GMT References: <1990Sep21.160343.18870@eagle.lerc.nasa.gov> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 16 In article <1990Sep21.160343.18870@eagle.lerc.nasa.gov> vvcns@mars.lerc.nasa.gov writes: [tries to read floating point numbers with fscanf(pointer,"%f",&arg); but gets only random numbers] May I suppose "arg" isn't declared as float, but as double? In this case "%lf" were the proper format specifier. (Because float-s are propagated to double-s if used as argument *values*, this problem doesn't appear in printf and hence is often overlooked with scanf.) Another possible source of problems are the "locales" (new in ANSI-C). The character which separates the decimal part may depend on the current locale and hence he locale should be the same for writing and reading floats. -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83