I'm trying to write a function that suppose to recieves a natural number and turn it into a string using a recursion, for example the number 123 will be {'1','2','3'}.
can someone please tell me why my code isn't working?
Code:
void intToStr(unsigned int num, char s[])
{
if(num/10==0)
{
s[0]=(char)(num+48);
s[1]='\0';
}
else
{
intToStr(num/10, s);
s[strlen(s)]=(char)(num%10+48);
s[strlen(s)+1]='\0';
}
}
