1.//将整数转换为字符串
#include<iostream>
using namespace std;
int main()
{
int num = 12345;
int i = 0,j = 0;
char temp[6],str[6];
while(num)
{
temp[i] = num%10 + '0';
i++;
num = num/10;
}
temp[i] = 0;//字符串以0做为结束符
cout<<temp<<endl;
i = i-1;
while(i>=0)
{
str[j]=temp[i];
i--;j++;
}
str[j]=0;
cout<<str<<endl;
return 1;
}
//将数组转换为整数
#include<iostream>
using namespace std;
int main()
{
char c[] = "12345";
cout<<c<<endl;
int i=0,temp,sum=0;
while(c[i])
{
temp = c[i]-'0';
sum = sum*10+temp;
i++;
}
cout<<sum<<endl;
return 1;
}
2.