www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/22/18:53:29

From: Brendan Simon <brendan AT rdt DOT monash DOT edu DOT au>
Date: Tue, 23 Jan 1996 10:43:24 +1100
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: scanf bug

> Hello,
> 
> I've found some strangeness in sscanf which I suspect to be a bug.
> I'm using v2beta4.
> 
> Here is a simple test program:
	stuff deleted here
> That is ch_read is uninitialized and sscanf succseeded! :-(
> 
> I think it is because a bug in doscan.c. It checks 'fileended' variable
> and immediately exits. But in the format string next token is '%n' which does
> not require more input.
> 

I too have recently had problems with fscanf when reading floating point
numbers (doubles) from a file.

eg.    fprintf("%10.4f %10.4f %10.4f", num1, num2, num3);

this is written to the file OK !!!  But when I try to read it with

       fscanf("%f %f %f", &temp1, &temp2, &temp3);
   OR
       fscanf("%lf %lf %lf", &temp1, &temp2, &temp3);

the variables have the value of 0.0.  This is wrong !!!!

When I use
       fscanf("%s %s %s", &temp_str1, &temp_str2, &temp_str3);

The values in the strings are CORRECT.  It seems to have problems with
the formating arguments.  An interesting thing is that I am using the
same method to save/load files with unsigned int types and they don't
SEEM to have any problems with scanf/fscanf ???

Hope this can be fixed or isolated soon.  Hope this helps.

Brendan Simon
brendan AT rdt DOT monash DOT edu DOT au


--CAA08389.822352348/video.yars.free.net--


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019