当先锋百科网

首页 1 2 3 4 5 6 7

(1)使用ostringstream;
ostringstram oss;
oss << a;
string s = oss.str();

(2)使用sprintf
char buf[20] = {0};
sprintf(buf, "%d", a);
string s = buf;

(3)使用itoa
char buf[20] = {0};
string s = itoa(a, buf, 10);

(4)使用MFC的CString::Format:
CString s0;
s0.Format("%d", a);

(5)使用boost的lexical_cast:
string s = boost::lexical_cast<string>(a);