I have this printf statement:
printf("name: %s\t"
"args: %s\t"
"value %d\t"
"arraysize %d\t"
"scope %d\n",
sp->name,
sp->args,
sp->value,
sp->arraysize,
sp->scope);
It’s inside a for loop, so it’s printing multiple lines for a list of pointers.
The problem is that if some of the things that are printed are longer or shorter, it causes things to not line up. How do I get it to always line up?
Each conversion specifier can be given a field width which give the minimum number of characters that conversion will use. There are other flags and precision that can be used to control the output (for example with the
%sconversion the precision item says how many characters maximum will be used).