Article View: comp.lang.c.moderated
Article #2313Re: 'h' modifier in printf
From: Dan Pop
Date: Sun, 17 Mar 1996 03:17
Date: Sun, 17 Mar 1996 03:17
19 lines
1098 bytes
1098 bytes
In <4iepq6$af6@solutions.solon.com> gordon@sneaky.lerctr.org (Gordon Burditt) writes:
>I don't think so, BUT:
>short s = -1;
>printf("%x\n", (unsigned int) s);
>printf("%hx\n", (unsigned int) s);
>
>/* is it allowed to leave out the casts? */
In practice, yes (any int value is likely to have a meaning as unsigned
int as well and they have the same size). Strictly speaking, leaving out
the cast invokes undefined behaviour, however.
Dan
--
Dan Pop
CERN, CN Division
Email: danpop@mail.cern.ch
Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Technical Details
Message-ID:
<4ig07u$fsp@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4i801c$455@solutions.solon.com> <4iepq6$af6@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: danpop@mail.cern.ch (Dan Pop) Newsgroups: comp.lang.c.moderated,comp.std.c Subject: Re: 'h' modifier in printf Date: 16 Mar 1996 21:17:18 -0600 Organization: CERN European Lab for Particle Physics Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4ig07u$fsp@solutions.solon.com> References: <4i801c$455@solutions.solon.com> <4iepq6$af6@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com X-Newsreader: NN version 6.5.0 #7 (NOV)