|
分析:
参数:数,字符串首地址(保存转换之后的字符串)
返回值:没有 不能返回栈上的地址(不能返回函数中变量的地址,函数结束了,变量就没有了)
void fun(int n,char *buf)
{
int i=0;
int l,r;
while(n!=0)
{
buf[i]=n%10+48;
i++;
n=n/10;
}
buf[i]='\0';
l=0;
r=i-1;
char tmp;
while(l<r)
{
tmp=buf[l];buf[l]=buf[r];buf[r]=tmp;
l++;
r--;
}
}
|