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