题目要求:用C语言编写实现如下函数,将无符号整数转换为字符串,例如将1234,转换为“1234”,不能使用itoa、sprintf等库函数。
#include <stdio.h>
void IntToAsc(unsigned int uiNum, unsigned char *sAscBuf)
{
unsigned char t, *p = sAscBuf;
for (; uiNum; p++)
{
*p = uiNum % 10 + '0';
uiNum /= 10;
}
*(p--) = 0;
for (; sAscBuf < p; sAscBuf++, p--)
{
t = *sAscBuf;
*sAscBuf = *p;
*p = t;
}
}
void main()
{
unsigned int i = 1234;
unsigned char s[100] = "";
IntToAsc(i, s);
printf("%s\n", s);
}