//This code will I guess increment the last digit example
012
013
014
.
.
019
The next number I guess would be to 023,024....
Can someone guide me as to how or where can I make this change in the code.
void PrintNumbers (int length)
{
int a[] ={0,1,2,3,4,5,6,7,8,9};
char result [length + 1];
int i;
for (i=0;i<length;i++)
result[i]= a[i];
//Main loop begins here
while (1) {
printf ( "%d"\n",result);
for (i=length-1 ; i>=-1;i--)
{
if (i==-1) return;
if (a[i] == result [i]) {
resullt [i] == a[i+1];
break;
}
}
}
}
Start at the right, increment it by 1, then scan to the left to see what else can be incremented.
You would only scan to the left if a more-right digit couldn't be incremented - in which case you would try to increment a digit to the left. When you find a digit that can be incremented, you would increment it then set all digits to the right of it equal to 1 more than the digit to their left.
Apparently English is my first language, but good luck understanding what I've just written; I'm sure it made sense when I wrote it.