C++的string容器->基本概念、构造函数、赋值操作、字符串拼接、查找和替换、字符串比较、字符存取、插入和删除、子串

慈云数据 1年前 (2024-03-18) 技术支持 51 0

#inClude

using NAMEspace std;

#include

//string的构造函数

/*

-string();                      //创建一个空的字符串 例如: string str;

-string(const char* s);           //使用字符串s初始化

-string(const string& str);   //使用一个string对象初始化另一个string对象

-string(int n, char c);      //使用n个字符c初始化

*/

void test01()

{

    string s1; //默认构造,创建空字符串,调用无参构造函数

    cout

微信扫一扫加客服

微信扫一扫加客服