你可以使用库函数 itoa()
# include
# include
void main (void)
{
int num = 100;
char str[25];
itoa(num, str, 10);//把int 类型的num 转换成 10 进制的字符串类型
printf("The number 'num' is %d and the string 'str' is %s. \n" ,
num, str);
}
itoa() 将整型值转换为字符串
sprintf(str, " %d" , num);
都可以