I know %%
is used to escape actual %
signs in a string, so %%%ds
will end up with %10s
in the following format string, but I don't know why I need %%5s
in this string?
After all, there are only two additional arguments (BUFFSIZE / 10).
#define BUFFSIZE 100
char buf[100]={0}
sprintf(buf, "%%5s %%%ds %%%ds", BUFFSIZE / 10, BUFFSIZE / 10);
After running the code above, the buf will contain the string,
%10s %10s
%5s %10s %10s
inbuf
, demo here ideone.com/c8MhN6. What did you expect? – Palliasse%*s
. – Nelsonnema