Article View: comp.lang.c.moderated
Article #2363Re: 'h' modifier in printf
From: Holden P
Date: Sat, 23 Mar 1996 06:48
Date: Sat, 23 Mar 1996 06:48
37 lines
1419 bytes
1419 bytes
printf("Vanilla %X\nWith h %hX\n", -1, -1);
says
Vanilla FFFFFFFF
With h FFFF
In article <4i801c$455@solutions.solon.com>,
tada@athena.mit.edu (Michael J Zehr) writes:
>
>I was recently asked a question about printf whose answer I couldn't
>determine by reading K&R2 (and alas the company doesn't have a copy of
>the standard to refer to).
>
>The "h" modifier says the corresponding argument will be printed as a
>short or unsigned short.
>
>So, given:
>
>short s;
>printf("%d", s);
>printf("%hd", s);
>
>(Assuming of course that s has been initialized at some point.)
>
>Can these two ever be different? I'm aware of course that the short is
>widened to an int during the function call, but this preserves the
>value.
>
>
>Thanks,
>michael j zehr
--
Phil Holden: AKA holdp@essex.ac.uk Phone: +44 (0) 1206 872142
ESRC Data Archive, University of Essex, Colchester, Essex C04, 3SQ, U.K
Technical Details
Message-ID:
<4j06rd$82n@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4i801c$455@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: holdp@essex.ac.uk (Holden P) Newsgroups: comp.lang.c.moderated,comp.std.c Subject: Re: 'h' modifier in printf Date: 23 Mar 1996 00:48:13 -0600 Organization: Essex University, England Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4j06rd$82n@solutions.solon.com> References: <4i801c$455@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com X-Newsreader: knews 0.9.3