🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2333

Re: 'h' modifier in printf

#2333
From: Stan Ryckman
Date: Tue, 19 Mar 1996 12:47
29 lines
1376 bytes
In article <4i98fl$8ml@solutions.solon.com>,
 <baynes@ukpsshp1.serigate.philips.nl> wrote:
>Michael J Zehr (tada@athena.mit.edu) wrote:

[snip]

>: This is the main question I'm interested, but as a followup, if these
>: always result in the same output, why is the 'h' modifier defined in the
>: first place?
>
>Probably so you can use the same format string with scanf.

AVOID THIS ASSUMPTION!!!

It's a common trap, and fails with floating point numbers.

"%f" ==> output a double (*printf)
"%f" ==> input a float (*scanf)

IMHO, the format strings *should* have been designed so that
the same one can be used to read back something written, but
this is not the case.  Sorry, they didn't ask me!  :-)

Cheers,
Stan.
--
Stan Ryckman  (stanr@tiac.net)
  (Apologies for non-responses or late responses to some posts;
  .newsrc was trashed and I'm trying to get it back to where it was.)
Technical Details
Message-ID: <4imack$duv@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4i801c$455@solutions.solon.com> <4i98fl$8ml@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: stanr@tiac.net (Stan Ryckman)
Newsgroups: comp.lang.c.moderated,comp.std.c
Subject: Re: 'h' modifier in printf
Date: 19 Mar 1996 06:47:16 -0600
Organization: Amber & Sneakers Fan Club
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4imack$duv@solutions.solon.com>
References: <4i801c$455@solutions.solon.com> <4i98fl$8ml@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com