This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
printf format specifiers
- From: "Steve Dondley" <s at dondley dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Sun, 20 Oct 2002 08:57:28 -0400
- Subject: printf format specifiers
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.