public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Roberto Díaz" <rdiazmartin@vivaldi.dhis.org>
To: Segher Boessenkool <segher@koffie.nl>
Cc: Steve Dondley <s@dondley.com>, gcc-help@gcc.gnu.org
Subject: Re: printf format specifiers
Date: Wed, 23 Oct 2002 19:01:00 -0000	[thread overview]
Message-ID: <1035432111.729.19.camel@corelli> (raw)
In-Reply-To: <3DB54CEF.84A93CA@koffie.nl>

[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

There was a list called tuxcprograming or something like that for C
programming doubts.. I am mention this because I see there are at times
some C programming doubts answered in this list which is supposed to be
a gcc list.. 

Anyway I dont care, it doesnt bother me this kind of messages.. but
maybe other do.


> In your case, "string" is a pointer to char, so *string is a char, which matches
> the first case above, so it is passed as int, so the format specifier "%d" works
> just fine.  If you use "%hu", printf() still reads an int, but converts it to
> an unsigned short.  Now either you didn't test this with negative char values,
> or your char happens to be an unsigned type; otherwise, "%hu" wouldn't have
> given the same output as "%d".
> 
> Btw, if you wanted to print it as a char value, instead of a short value, you
> should have used "%hhd" or "%hhu".
> 
> Hope this clarifies things for you,
> 
> 
> Segher
> 
> 
> 
-- 

gnupg public key at: wwwkeys.pgp.net

[-- Attachment #2: Esta parte del mensaje esta firmada digitalmente --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

      reply	other threads:[~2002-10-24  2:01 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
2002-10-21  6:33 ` John Love-Jensen
2002-10-23 18:38 ` Segher Boessenkool
2002-10-23 19:01   ` Roberto Díaz [this message]

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=1035432111.729.19.camel@corelli \
    --to=rdiazmartin@vivaldi.dhis.org \
    --cc=gcc-help@gcc.gnu.org \
    --cc=s@dondley.com \
    --cc=segher@koffie.nl \
    /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).