#include <stdio.h>
#include <string.h>
void /* params: maxcolums, currentcolumn, currentrow, column separator, column width */
dumpcol (int mc, int c, int r, char s, int cw)
{
if (c < mc)
{
char fs[9];
sprintf (fs, "%%%dd%%c", cw);
if (c == mc - 1)
sprintf (fs, "%%%dd", cw);
printf (fs, ++c + mc * r, s);
dumpcol (mc, c, r, s, cw);
}
}
void /*params: maxcolums, maxrows, currentrow, column separator, column width, lineseparator */
dumptable (int mc, int mr, int r, char s, int cw, char *ls)
{
dumpcol (mc, 0, r, s, cw);
printf ("%s", ls);
if (++r < mr)
dumptable (mc, mr, r, s, cw, ls);
}
int
main ()
{
dumptable (10, 12, 0, ' ', 3, "\n");
return 0;
}