Xref: utzoo comp.sys.mac:46044 comp.sys.mac.programmer:11679 Path: utzoo!attcan!uunet!ns-mx!ceres!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!deimos!deimos.ads.com!adiseker From: adiseker@deimos.ads.com (Andrew Diseker) Newsgroups: comp.sys.mac,comp.sys.mac.programmer Subject: ThinkC *scanf() problems... Keywords: scanf sscanf fscanf bugs? Message-ID: <10387@deimos.ADS.COM> Date: 12 Jan 90 03:27:53 GMT Sender: adiseker@deimos.ADS.COM Distribution: na Organization: Advanced Decision Systems, Mt. View, CA (415) 960-7300 Lines: 46 Some time back, someone mentioned they were having problems with scanf() in the ThinkC 4.0 ANSI library. I copied someone (else's?) response which contained a 2-line patch to scanf.c. I made that fix, but I'm still having a devil of a time trying to use the scanf family. I have a text file which contains floating point numbers, which I am trying to read in to separate floats. The following is the code I'm using to test. #include main() { float a = 1.2, b = 2.1, c, d; FILE *fptr; char *fileName = "sam"; char buffer[100]; fptr = fopen(fileName, "w+" ); fprintf(fptr, "%f %f", a, b, c, d ); fclose(fptr); fptr = NULL; fptr = fopen(fileName, "r+" ); /* this was the first way I tried fscanf( fptr, "%f %f", &c, &d ); */ /* this was the second way I tried */ fgets( buffer, 100, fptr ); printf("%s from file\n", buffer ); sscanf( buffer, "%f %f", &c, &d ); printf( "a = %f, b = %f, c = %f, d = %f\n", a, b, c, d ); fclose( fptr ); } Both the commented-out fscanf and the sscanf had the same effect: a remained unchanged, b got trashed, c and d were set to garbage. Has anyone fixed this, and are source code patches available? This is holding up some critical work that I'd just as soon be done with, so I can go on to even more critical work %*( E-mail replies requested, but I do try to keep up on this group. Ocheyn Spaceeba!