字符串数字与数值型数字

#include<string>
//stol()、stoll() 、stoul()、stoull()、stof()、stod()  和 stold()
string str = "1234";
double d = stod(str);

c++11标准增加了全局函数std::to_string:

string to_string (int val);
string to_string (long val);
string to_string (long long val);
string to_string (unsigned val);
string to_string (unsigned long val);
string to_string (unsigned long long val);
string to_string (float val);
string to_string (double val);
string to_string (long double val);
posted @ 2020-02-01 18:30  friedCoder  阅读(223)  评论(0编辑  收藏  举报