/**
将整型转换成字符串 不使用atoi
*/
#include <stdio.h>
#include <iostream>
int main(void)
{
int num = 15265, j = 0, i =0;
char temp[7], str[7];
while(num)
{
temp[i] = num%10 + '0';
i++;
num = num /10;
}
temp[i] = 0;
printf("temp = %s\n", temp);
i--;
printf("temp = %d\n", i);
//逆序
while(i >= 0)
{
str[j] = temp[i];
j++;
i--;
}
str[j] = 0;
printf("str = %s\n", str);
return 0;
}
整型转字符串
最新推荐文章于 2025-03-31 18:50:44 发布