字符串和数字的相互转化
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int num=0;
char *p=new char[11];
gets(p);
cout<<*p;
while(*p!='\0')
{
num=num*10+*p-'0';
p++;
}
cout<<num;
}
{ int num,n=0;
char *p=new char[11];
char *h=p;
cin>>num;
while(num>0)
{
*p=num%10+'0';
num=num/10;
n++;
p++;
}
*p='\0';
char *str=new char[11];
str[n]='\0';
n--;
cout<<n;
while(*h!='\0')
{
str[n]=*h;
n--;
h++;
}
cout<<str;
}