I have to place list into an array....I think that it is working except the 0 position is repeating(only this one)

Can anyone help?

Code:
```//******************************************************************BUCKET SORT
void bucket_sort(int digit)
{
node *buckets[10];
node *temp, *temp2;
temp = start_ptr;
int i;
int digit_num;

for(i=0; i<10; i++)
{
buckets[i] = NULL;
}

do
{  if (temp == NULL)
{
}
else
{
digit_num = get_digit(temp->node_struct,digit);
//cout << "Digit = " << digit_num << endl;
if(digit_num == 0)
{
if(buckets[0] == NULL)
{
cout << " A ZERO DIGIT" << endl;
buckets[0] = temp;
}
else
{
buckets[0]->nxt = temp;
}
}
else if(digit_num == 1)
{
if(buckets[1] == NULL)
{
cout << " A ONE DIGIT" << endl;
buckets[1] = temp;
}
else
{
buckets[1]->nxt = temp;
}
}
else if(digit_num == 2)
{
if(buckets[2] == NULL)
{
cout << " A TWO DIGIT" << endl;
buckets[2] = temp;
}
else
{
buckets[2]->nxt = temp;
}
}
else if(digit_num == 3)
{
if(buckets[3] == NULL)
{
cout << " A THREE DIGIT" << endl;
buckets[3] = temp;
}
else
{
buckets[3]->nxt = temp;
}
}
else if(digit_num == 4)
{
if(buckets[4] == NULL)
{
cout << " A FOUR DIGIT" << endl;
buckets[4] = temp;
}
else
{
buckets[4]->nxt = temp;
}
}
else if(digit_num == 5)
{
if(buckets[5] == NULL)
{
cout << " A FIVE DIGIT" << endl;
buckets[5] = temp;
}
else
{
buckets[5]->nxt = temp;
}

}
else if(digit_num == 6)
{
if(buckets[6] == NULL)
{
cout << " A SIX DIGIT" << endl;
buckets[6] = temp;
}
else
{
buckets[6]->nxt = temp;
}

}
else if(digit_num == 7)
{
if(buckets[7] == NULL)
{
cout << " A SEVEN DIGIT" << endl;
buckets[7] = temp;
}
else
{
buckets[7]->nxt = temp;
}
}
else if(digit_num == 8)
{
if(buckets[8] == NULL)
{
cout << " A EIGHT DIGIT" << endl;
buckets[8] = temp;
}
else
{
buckets[8]->nxt = temp;
}
}
else if(digit_num == 9)
{
if(buckets[9] == NULL)
{
cout << " A NINE DIGIT" << endl;
buckets[9] = temp;
}
else
{
buckets[9]->nxt = temp;
}
}

temp2 = temp->nxt;
temp->nxt = NULL;
temp = temp2;
}
}while (temp != NULL);

}```

2. This should do what you want:

This function will return your digit amount in an int, but will return 0 if there are more than 'maxdigits' digits.

Code:
```int bucket_sort(int digit, int maxdigits)
{
char c[maxdigits + 3];
wsprintf(c,"%d",digit);
int i;
for(i = 0; i <= maxdigits; i++)
if(c[i] == '\0')
break;
if(i == maxdigits)
return 0;
return i;
}```