- <code class="language-cpp" deep="7">
- #include<iostream>
- #include<string>
- using namespace std;
- int main()
- {
- string s1 = "2018.11";
- int a1 = stoi(s1);
- double c = stod(s1);
- float d = stof(s1);
- int a2 = a1 + 1;
- string b = to_string(a1);
- b.append(" is a string");
- cout << a1 <<"/"<<c<<"/"<<d<<"/"<<a2<<"/"<<b<< endl;
- }</code>
C++字符串数值的转换(to_string/stoi/stod)
猜你喜欢
转载自blog.csdn.net/u010112268/article/details/81258811
今日推荐
周排行