For example: input 123, it will be converted into the string "123"
#include
void dtoc(long a, char str[]);
int main()
{
long intg;
char istr[20];
for(int i=0; i<20; i++)
< p> istr[i] = '\0';printf("Please input a long integer:");
scanf("%d", &intg); p>
dtoc(intg, istr);
printf("%s\n", istr);
return 0;
}< /p>
void dtoc(long a, char str[])
{
static int t=0;
if(a > 0 )
{
dtoc(a/10, str);
str[t++] = a%10 + '0';
< p> }else if(a == 0)
{
str[t] = '0';
return ;
}
else
{
str[t++] = '-';;
a = -a;
dtoc(a, str);
}
}