home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18945 < prev    next >
Encoding:
Text File  |  1992-12-29  |  869 b   |  26 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!news!manta!mitch
  3. From: mitch@nosc.mil (Ray Mitchell)
  4. Subject: Scanf field width macro?
  5. Message-ID: <1992Dec28.213129.8983@nosc.mil>
  6. Organization: Naval Ocean Systems Center, San Diego, CA
  7. Date: Mon, 28 Dec 1992 21:31:29 GMT
  8. Lines: 16
  9.  
  10.  
  11. Consider the statements
  12.  
  13.    printf("%*s", field_width, char_buffer);
  14.     scanf("%5s", char_buffer);
  15.  
  16. I would like to avoid embedding the magic field width constant in the
  17. scanf.  I don't need it to be a variable field width like in printf
  18. but only need it to be in terms of some constant width macro I've
  19. previously defined.  I've tried various things using stringization,
  20. token pasting, etc. to no avail.  A solution which does not depend
  21. on some non-standard preprocessor/compiler behavior is required.
  22.  
  23. Thanks,
  24. Ray Mitchell
  25. mitch@nosc.mil
  26.