整型轉成字符串不用itoa

<span style="font-size:24px;">#include<stdio.h>
#include<windows.h>
void main()
{
	int num =12345,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=i-1;
	printf("temp %d\n",i);
	while(i>=0)
	{
		str[j]=temp[i];
		j++;
		i--;
	}
	str[j]=0;
	printf("string=%s\n",str);
	system("pause");
}</span>

發佈了35 篇原創文章 · 獲贊 9 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章