What does printf("%*.*s",int,int,char *) mean in c? -
this question has answer here:
- what “%.*s” mean in printf? 3 answers
i got code snippet in there statement
printf("%*.*s"); what %*.*s mean?
the code is
char *c="**********"; int i,n=4; for(i=1;i<=n;i++) { printf("%*.*s\n",i,i,c); } output is:
* ** *** ****
read spec of printf:
%[flags][width][.precision][length]specifier
sstring of characters
*width not specified in format string, additional integer value argument preceding argument has formatted.
for strings width minimum number of characters printed (padding may added).
.*precision not specified in format string, additional integer value argument preceding argument has formatted.
for strings precission maximum number of characters printed.
your program not passing required optional arguments (witdh, precission, string printed). behavior undefined (likely crash).
Comments
Post a Comment