Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!mailrus!cornell!uw-beaver!rice!sun-spots-request From: davis@handies.ucar.edu (Glenn P. Davis) Newsgroups: comp.sys.sun Subject: Sun OS 4 scanf problem Message-ID: <1238@ncar.ucar.edu> Date: 19 Jan 89 07:19:33 GMT Sender: usenet@rice.edu Organization: Unidata/UCAR, Boulder Lines: 45 Approved: Sun-Spots@rice.edu Original-Date: 14 Jan 89 00:16:27 GMT X-Sun-Spots-Digest: Volume 7, Issue 112, message 3 of 14 /* * Hi. * * The following program demonstrates a problem with * the scanf family of functions under SunOS 4. * * The problem has been observed on a sun3 and on a sun4 running Sun OS 4.O.1. * The problem was has been observed with fscanf as well as sscanf. * * Thanks. * * Glenn P. Davis * UCAR / Unidata * PO Box 3000 1685 38th St. * Boulder, CO 80307-3000 Boulder, CO 80301 * * (303) 497 8643 */ char string[] = "00235 01162 18019 85514 05980 24531 70009 14360 26042 50550 28748 26083" ; main() { int cnt ; float h, t, td, dir, spd ; printf("Should scan as:\n") ; printf("cnt: 5; 235.000000 11.000000 62.000000 180.000000 19.000000\n") ; cnt = sscanf( string,"%*2s%3f %3f%2f %3f%2f", &h, &t, &td, &dir, &spd) ; printf("In fact scans as:\n") ; printf( "cnt: %d; %f %f %f %f %f\n", cnt, h, t, td, dir, spd) ; } /* * Workaround: * Change: cnt = sscanf( string,"%*2s%3f %3f%2f %3f%2f", &h, &t, &td, &dir, &spd) ; * To: cnt = sscanf( string,"%*2s%f %3f%f %3f%f", &h, &t, &td, &dir, &spd) ; */