#include <iostream>
using namespace std;
int main()
{
//int num = 12345;
//char string[7];
//itoa(num,string,10); //整型转换成字符
//cout<<"num = "<<num<<",";
//for (int i = 0;string[i] != '\0';i++)
//{
// cout<<string[i];
//}
//cout<<endl;
int num = 123456;
int intNum[7];
char charNum[7];
int i = 0;
int j = 0;
int k = 0;
cout<<"num = "<<num<<",";
while ((intNum[i ++] = num % 10) > 0)
{
num /= 10;
}
k = i --; //因为最后while循环跳出是num是0,所以i = 7
while(-- i > -1)
{
//charNum[j ++] = (char)(intNum[i] + 48);
charNum[j ++] = intNum[i] + '0';
}
for (int i = 0;i < k;i++)
{
cout<<charNum[i];
}
cout<<endl;
return 0;
}
using namespace std;
int main()
{
//int num = 12345;
//char string[7];
//itoa(num,string,10); //整型转换成字符
//cout<<"num = "<<num<<",";
//for (int i = 0;string[i] != '\0';i++)
//{
// cout<<string[i];
//}
//cout<<endl;
int num = 123456;
int intNum[7];
char charNum[7];
int i = 0;
int j = 0;
int k = 0;
cout<<"num = "<<num<<",";
while ((intNum[i ++] = num % 10) > 0)
{
num /= 10;
}
k = i --; //因为最后while循环跳出是num是0,所以i = 7
while(-- i > -1)
{
//charNum[j ++] = (char)(intNum[i] + 48);
charNum[j ++] = intNum[i] + '0';
}
for (int i = 0;i < k;i++)
{
cout<<charNum[i];
}
cout<<endl;
return 0;
}