Now I understand, sorry
You can solve this with a recursive function. Here a quick (and dirty) solution:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int print_numbers(int col, int nr, int max_col, int max_nr, char *line)
{
char line2[BUFSIZ];
char number[BUFSIZ];
if(col <= max_col)
{
for(++col; nr <= max_nr; nr++)
{
sprintf(line2, "%s%d ", line, nr);
print_numbers(col, nr+1, max_col, max_nr, line2);
}
}
else
printf("%s\n", line);
return 0;
}
int main(int argc, char *argv[])
{
char line[BUFSIZ] = {0};
return print_numbers(1, 1, 4, 6, line);
}
The code is buggy (no dynamic allocation of buffer) but it might give you some ideas how to solve your problem.