标签:
1.string --> char *
char * p = (char*)str.c_str();
2.char * -->string
char *p = "aaa";
string str(p);
3.int-->string
int n=100000; char t[38]; int i = 0; if (n != 0) { while (n) { t[i++] = (n % 10) + ‘0‘; n /= 10; } t[i] = 0; } else t[i] = ‘0‘; return string(_strrev(t));
4.string-->number
#include <iostream> #include <sstream> template <class Type> Type string2Num(const string& str) { istringstream iss(str); Type num; iss >> num; return num; }
待续....
标签:
原文地址:http://www.cnblogs.com/WonderHow/p/4541126.html