public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* printf format specifiers
@ 2002-10-20  5:52 Steve Dondley
  2002-10-20  7:14 ` Der Herr Hofrat
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Steve Dondley @ 2002-10-20  5:52 UTC (permalink / raw)
  To: gcc-help

Hi,

I have the following line in one of my programs:

printf("%d\n", *string);

*string is a pointer to a string.  The above line prints out the ASCII
decimal equivalent of the character that the pointer is pointing to.  This
is what I was looking to accomplish.

My question is why?  Why wouldn't I need to use the %hu (unsigned short
integer) format specifier?  When I do use the %hu, I get precisely the same
results.  This despite the fact that %d reads an entire word and %hu reads a
single byte.

Is this some compiler magic going on here?

Thanks.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-10-24  2:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-20  5:52 printf format specifiers Steve Dondley
2002-10-20  7:14 ` Der Herr Hofrat
2002-10-21  6:33 ` John Love-Jensen
2002-10-23 18:38 ` Segher Boessenkool
2002-10-23 19:01   ` Roberto Díaz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).