home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!milton!adrian
- From: adrian@milton.u.washington.edu (Adrian Mariano)
- Newsgroups: comp.lang.c
- Subject: scanf portability (?) problem
- Keywords: scanf
- Message-ID: <adrian.714869816@milton>
- Date: 26 Aug 92 22:56:56 GMT
- Sender: news@u.washington.edu (USENET News System)
- Organization: University of Washington
- Lines: 31
-
-
- I'm trying to parse lines which look like the ones below. Most lines
- will look like the top one, but in a few cases, the text in the second
- and or third set of brackets will be 5 characters instead of 3
- characters (like the second line below).
-
- [ 0] nimmox [ 6k] vs. cd [ 9k] ( 99 19 0 5.5)
- [ 5] joe [IGS92] vs. xxxyyyz [???] ( 33 11 3 4.5)
-
-
- In order to do this, I wrote the following scanf pattern:
-
- "[%2d]%12s [%[^]]] vs.%12s [%[^]]] (%3d %d %d %f)\n"
-
- ^ ^
- | |
- -----------------
- |
- |
- These are the troublemakers
-
- Earlier, the program whose output I am parsing would only generate
- lines which look like the first one above. I assumed that the text in
- brackets was always three characters, and parsed it with %3c. This
- worked correctly everywhere I tried it.
-
- With the change, everything works fine on all machines I've tried but
- one machine running Dynix. Is there something I can do to make this
- scanf pattern work everywhere?
-
- Please email responses.
-