home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12881 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  735 b 

  1. Path: sparky!uunet!mcsun!sunic!dkuug!login.dkuug.dk!kimcm
  2. From: kimcm@login.dkuug.dk (Kim Chr. Madsen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: printf question
  5. Message-ID: <kimcm.714943581@login.dkuug.dk>
  6. Date: 27 Aug 92 19:26:21 GMT
  7. References: <1992Aug27.143434.26965@dartvax.dartmouth.edu>
  8. Sender: news@slyrf.dkuug.dk
  9. Lines: 17
  10.  
  11. eht@coos.dartmouth.edu (Edward H. Truex) writes:
  12.  
  13.  
  14. >I am trying to format a hexadecimal number whose width 
  15. >is always a constant - like 
  16.  
  17. >    printf("%04x\n", address );
  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.  
  27.                     Kim Chr. Madsen
  28.