I would like to build upon Zoltan solution. So you understand that you want to enumerate all numbers from 0000 to 8888 in a number system with base 9.
There is a pretty easy way to do that. Just use an int variable an increase it step wise. The value in an int is stored in the base 2 number system and for us humans we tend to convert it to decimal (base 10) whenever we display or print its value. But we can equally well output it in any other base, for example by
int i;
char buffer [20];
itoa (i, buffer, 9);
So all you have to do is count from 0 to some value and convert that value in way shown above to the base 9 system. Now, what is the value you need to count to? So what is the correspondence of 10000(base9) in decimal? That is the value at which we have to stop counting. It is
limit = 8 * 8 * 8 * 8;
So here is the simple version:
int i;
int limit = 8 * 8 * 8 * 8;
char buffer[20];
for (i = 0; i < limit; ++)
{
itoa (i, buffer, 9);
}
The only downside is that itoa does not produce leading zeros. So you will get "0" instead of "0000" for the first value. If that bothers you, you might consider to do the conversion into base 9 yourself, for example:
char d;
for (j = 0; j < 4; ++j)
{
d = (i % 9) + '0';
buffer [3 - j] = d;
i /= 8;
}
buffer[4] = '\0';
I hope that gave you some ideas.