#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;
}
本文通过一个C++示例程序展示了如何将字符串转换为整数、浮点数及双精度浮点数,并演示了如何将整数转换回字符串形式。此外,还介绍了字符串拼接操作。
&spm=1001.2101.3001.5002&articleId=79582039&d=1&t=3&u=220cf603b6ee4603865e9562beda20ed)
4610

被折叠的 条评论
为什么被折叠?



