Я пытаюсь этот код преобразовать целые числа в строку. Он печатает значения, но ничего не возвращает вызывающей функции
char* itoa(int num, int num_len)
{
char str[num_len+2];
int i;
//if the num is 0
if(num == 0)
strcpy(str, "0");
//if the num is negetive then we append a '-' sign at the beginning
//and put '\0' at (num_len+1)th position
else if(num < 0)
{
num *= -1;
str[num_len+1] = '\0';
str[0] = '-';
i = num_len+1;
}
//we put '\0' (num_len)th position i.e before the last position
else
{
str[num_len] = '\0';
i = num_len;
}
for(;num>0;num/=10,i--)
{
str[i] = num%10 + '0';
printf("%c ",str[i]);//for debugging
}
return str;
}