From: Der Herr Hofrat <der.herr@mail.hofr.at>
To: Steve Dondley <s@dondley.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: printf format specifiers
Date: Sun, 20 Oct 2002 07:14:00 -0000 [thread overview]
Message-ID: <200210201315.g9KDFBl32057@hofr.at> (raw)
In-Reply-To: <FAECKOGIHAIBBPKBOKGNIEFADOAA.s@dondley.com> from Steve Dondley at "Oct 20, 2002 08:57:28 am"
> 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.
I guess you would see a difference if you would use ascii chars above 127 as
the one would change sign the other would not - and hu would read a short
which is 2bytes instead of 4 but I don_t see why %hu should read one byte
only.
hofrat
next prev parent reply other threads:[~2002-10-20 14:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-20 5:52 Steve Dondley
2002-10-20 7:14 ` Der Herr Hofrat [this message]
2002-10-21 6:33 ` John Love-Jensen
2002-10-23 18:38 ` Segher Boessenkool
2002-10-23 19:01 ` Roberto Díaz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200210201315.g9KDFBl32057@hofr.at \
--to=der.herr@mail.hofr.at \
--cc=gcc-help@gcc.gnu.org \
--cc=s@dondley.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).