Integer to string
Use recursion to convert an integer n into a string. For example, if you enter 483, the string "483" should be output. The number of digits of n is uncertain and can be a positive integer of any number of digits.
The input is only one line and contains a positive integer not exceeding 1000000.
Output the corresponding string.
Please pay attention to the line ending output.
enter
123875
Output
123875
//整数转换为字符串
#include <iostream>
#define N 7 //位数上限
using namespace std;
int main(void)
{
int i;
char a[N],b[N+1];
char *p=a;
long int n;
cin>>n;
while (n>0)
{
*p=n%10+48; //字符‘0’的ASCII
n/=10;
p++;
}
for (i=N-1;i--;i>0)
cout<<a[i];
cout<<endl;
return 0;
}