Possible Duplicate:
what does “%.*s” mean in printf in c
I know this question has for sure been asked elsewhere, but searching “%.*s” yields nothing meaningful on SO. Could someone please explain the following line to me?
printf("%.*s", len, buffer);
It limits the output to at most
lencharacters. The.starts the ‘precision’; the*says ‘use anintfrom the argument list to determine the precision’. Note that the ‘string’ (buffer) does not even have to be null terminated if it is longer thanlen.All this is easily found in the manual page for
printf().