home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!acorn!jcoxhead
- From: jcoxhead@acorn.co.uk (Jonathan Coxhead)
- Newsgroups: comp.lang.c
- Subject: Re: printf question
- Message-ID: <18260@acorn.co.uk>
- Date: 2 Sep 92 11:07:05 GMT
- References: <1992Sep01.214725.6334@ima.isc.com>
- Sender: jcoxhead@acorn.co.uk
- Organization: Acorn Computers Ltd, Cambridge, England
- Lines: 23
-
-
- In article "Re: printf question" karl@ima.isc.com (Karl Heuer) writes
- parenthetically
-
- The C preprocessor has no way to evaluate-and-stringise a constant
- expression.
-
- but it does!
-
- #define STR_(s) #s
- #define STR(s) STR_ (s)
-
- #define WIDTH 8
-
- printf ("%" STR (WIDTH) "x", n);
-
- Easy. I keep the first two lines in a central place for whenever I need
- them, along with other useful stuff.
-
- /|
- (_|/
- /|
- (_/
-