I understand that, with an oversize string, you can print out the first few characters with:
printf(".5s\n",string);
and with an undersize string, you can pad it with space:
printf("% 5s\n",string);
Is there a way to achieve both of these at once? i.e. pad it with 0 or space if it's short, and truncate it if it's long?