home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12973 < prev    next >
Encoding:
Text File  |  1992-08-30  |  1.9 KB  |  49 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!kth.se!news.kth.se!RICHARD
  3. From: RICHARD@CLYDE.ttt.kth.se
  4. Subject: Re: printf question
  5. In-Reply-To: wenner@einstein.eds.com's message of 28 Aug 92 18:09:32 GMT
  6. Message-ID: <RICHARD.92Aug30153124@CLYDE.ttt.kth.se>
  7. Sender: usenet@kth.se (Usenet)
  8. Nntp-Posting-Host: clyde.ttt.kth.se
  9. Organization: Department of TeleTransmission Theory
  10. References: <1992Aug27.143434.26965@dartvax.dartmouth.edu> <kimcm.714943581@login.dkuug.dk>
  11.     <1226@pascal.einstein.eds.com>
  12. Date: Sun, 30 Aug 1992 14:31:24 GMT
  13. Lines: 34
  14.  
  15.    In article <kimcm.714943581@login.dkuug.dk> kimcm@login.dkuug.dk (Kim Chr. Madsen) writes:
  16.  
  17. [... text deleted ...]
  18.  
  19.    >try to use the variable width specification method:
  20.    >
  21.    >    printf("%0*x\n",4, adress);
  22.    >
  23.    >an asteriks in the width specification is taken as a variable that
  24.    >must be taken from the arguments and be evaluated at runtime...
  25.  
  26.    The above will work just fine, but if you have a full ANSI compiler, the
  27.    syntax ...
  28.  
  29.    #define HDPI "4" /* Hex Digits Per Int */
  30.  
  31.        printf( "%0" HDPI "x\n", address );
  32.  
  33. [... text deleted ...]
  34.  
  35.    And if you have read this far, you surely won't mind one more irrelevant
  36.    remark ;-)  Using this syntax on the original problem will save you some
  37.    time because the format is evaluated at compile time instead of run time.
  38.  
  39. Huh????? Since when is the format evaluated at compile time? I've never
  40. seen that done!
  41.  
  42. --
  43. !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
  44. ! Richard Levitte, System manager       ! tel: int+46-8-790 64 23           !
  45. ! Royal Institute of Technology         ! fax: int+46-8-791 76 54           !
  46. ! Department of Teletransmition Theory  ! Internet: richard@ttt.kth.se      !
  47. ! S-100 44 Stockholm, Sweden            !                                   !
  48. !---------------------------------------------------------------------------!
  49.