Ray Butterworth <rbutterw@watmath.waterloo.edu> (04/26/91)
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?gwyn@smoke.brl.mil (Doug Gwyn) (04/27/91)
In article <1991Apr26.143651.18289@watmath.waterloo.edu> rbutterw@watmath.waterloo.edu (Ray Butterworth) writes: >Shouldn't the precision of 0 guarantee that no output will occur, >or does using the bad pointer mean all bets are off? "The argument SHALL be a pointer to an array of character type." Violation of a "shall" produces undefined behavior. You're lucky it didn't ABEND.