1 Star 0 Fork 1

llongger/Code_C++

forked from GodOuO/Code_C++ 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
62.string_data.cpp 581 Bytes
一键复制 编辑 原始数据 按行查看 历史
GodOuO 提交于 2023-03-15 04:08 . Train
#include<iostream>
#include<string>
using namespace std;
//string 赋值操作
void test01(){
string s1 = "Hello world";
cout<<"S1 : "<<s1<<endl;
string s2 = s1;
cout<<"S2 : "<<s2<<endl;
string s3;
s3 = 'a';
cout<<"S3 : "<<s3<<endl;
string s4;
s4.assign("Hello C++");
cout<<"S4 : "<<s4<<endl;
string s5;
s5.assign("Hello C++",5);
cout<<"S5(pre 5) : "<<s5<<endl;
string s6;
s6.assign(s5);
cout<<"S6 : "<<s6<<endl;
string s7;
s7.assign(10,'w');
cout<<"S7 : "<<s7<<endl;
}
int main(){
test01();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/llongger/codeCpp.git
git@gitee.com:llongger/codeCpp.git
llongger
codeCpp
Code_C++
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385