What is wrong with this program?
Guy Harris
guy at sun.uucp
Sat Aug 17 13:43:02 AEST 1985
> Not really, you are forgetting that the format "%.8s" will
> cause printf to print up to a null or 8 chars max. Unfortunately
> this style of printf can not be used with sizeof for compile time
> format changes without run time code support.
True, you can't have the compiler generate the "printf" string, but you can
do
printf("%.*s", sizeof(thing), thing);
since you can use "*" for a field width or precision and pick up the value
from the argument list.
Guy Harris
More information about the Comp.lang.c
mailing list