Article View: comp.std.c
Article #2811printf precision for strings
From: Ray Butterworth
Date: Fri, 26 Apr 1991 14:36
Date: Fri, 26 Apr 1991 14:36
11 lines
857 bytes
857 bytes
Consider the statement:
printf("%.*s", len, data);
If len==0, this should produce no output.
But, what if data==(char*)0 too?
With some compilers it produces the string "<nil>".
(I realize this "<nil>" is just a silly way of avoiding dumping core
or producing meaningless garbage, but that's not what I'm asking about.)
Shouldn't the precision of 0 guarantee that no output will occur,
or does using the bad pointer mean all bets are off?
Technical Details
Message-ID:
<1991Apr26.143651.18289@watmath.waterloo.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!rbutterwShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!rbutterw From: Ray Butterworth <rbutterw@watmath.waterloo.edu> Subject: printf precision for strings Message-ID: <1991Apr26.143651.18289@watmath.waterloo.edu> Sender: rbutterw@watmath.waterloo.edu (Ray Butterworth) Organization: Math Faculty Computing Facility, University of Waterloo Date: Fri, 26 Apr 1991 14:36:51 GMT Lines: 11