字符串转成数字
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str("1234");
const char *p;
int n;
p = str.c_str();//返回c字符串
n = atoi(p);
cout << n << endl;
return 0;
}
数字转成字符串
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n = 65535;
char t[256];
string s;
sprintf(t, "%d", n);
s = t;
cout << s << endl;
return 0;
}