Article View: comp.std.c
Article #3853Re: Why "long long" doesn't work.
From: Thad Smith
Date: Thu, 24 Aug 1995 21:46
Date: Thu, 24 Aug 1995 21:46
47 lines
2003 bytes
2003 bytes
In article <41crmm$o3u@newsbf02.news.aol.com>,
ffarance@aol.com (FFarance) wrote:
>The "printf" and "scanf" funcitons are extended via the "?" type modifier.
>For example:
>
> printf("%?d",precof(x),x);
>
>will always work. Think of "?" as a combination of "*" (takes the next
>argument) and "l" and "h" (the type modifiers).
In article <41g85d$kc@newsbf02.news.aol.com>,
ffarance@aol.com (FFarance) wrote:
>> From: geisler@mcs.anl.gov (Jonathan Geisler)
>>
>> It seems like a little overkill to have to always include a ?/precof()
>> combination for any precision number. Why not define a new modifier
>> that will automatically do the same lookup as precof() without the need
>> for the programmer to explicitly state it? So, for example, the 2 above
>> examples become (assuming the new modifier is 'P'):
>>
>> printf("%P", x); AND
>> printf("%*P", field_width, x);
>>
>> This looks much more reasonable and readable to me.
>
>How would this lookup work?
I can think of something in between these two proposals that might be
a little better. You could use something like
#define vpi(x) precof(x),(x) /* variable precision int */
printf("%D", vpi(x));
The format %D would specify two values being passed: an int specifying
the precision, followed by the actual value. This might be in
addition to %?d. Formats %u, %x, %o, and %i could be similarly
extended.
Although trickier, this might also be used for *scanf:
#define vpip(x) precof(*(x)),(x) /* variable precision int ptr */
sscanf (s, "%D", vpip (&x));
Thad
Technical Details
Message-ID:
<6kOPwQ9ytllY084yn@csn.net>Path:
arc1-ca.pugleaf.net!teal.csn.net!not-for-mailReferences:
<41fdv8$ici@milo.mcs.anl.gov> <41g85d$kc@newsbf02.news.aol.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!teal.csn.net!not-for-mail From: thads@csn.net (Thad Smith) Newsgroups: comp.std.c Subject: Re: Why "long long" doesn't work. Date: 24 Aug 1995 15:46:26 -0600 Organization: T3 Systems Message-ID: <6kOPwQ9ytllY084yn@csn.net> References: <41fdv8$ici@milo.mcs.anl.gov> <41g85d$kc@newsbf02.news.aol.com> Reply-To: ThadSmith@acm.org NNTP-Posting-Host: 199.117.27.22