in reply to Printing an array columnwise or rowwise

You said:
I don't manage justifying left with sprintf().

I take that to mean you just haven't learned yet how this is done; ikegami showed how to do this in his initial reply, but he didn't explain (yet). By putting a minus sign immediately after the "%" in the format string, you tell (s)printf to left-justify the printable value within the specified field width (mnemonic: positive field width is right-justified, negative field width is left justified).

The other trick he demonstrates is the use of "*" instead of a numeric for the field width, which tells (s)printf to take the next available arg in the arg list as the field width.

  • Comment on Re: Printing an array columnwise or rowwise