整数转成字符串

来源:互联网 发布:无线信号放大软件 编辑:程序博客网 时间:2024/06/05 10:12
//整数转成字符串,可以采用加'0',再逆序的办法,整数加'0'就会隐性转成char类型的数#include<stdio.h>int main(void){int num=123456;int i=0,j=0;char temp[7],str[7];while(num){temp[i]=num%10+'0';printf("%c\n",temp[i]);i++;num=num/10;}temp[i]=0;printf("temp=%s",temp);i=i-1;while(i>=0){str[j++]=temp[i--];}str[j]='\0';printf("str=%s",str);}

原创粉丝点击