c++ STL中string的使用方法

stl string常用函数 很全的STL string类的函数方法,便于查询 立即下载

1 <string>

string字符串尾部没有\0。

string在长度扩展后,可能会发生内存重新分配。所以,迭代器、指针在内存重新分配后会失效。

 

1.1 定义

string s1;        默认构造函数,s1为空串

strings2(s1);          将s2初始化为s1的一个副本

strings3("valuee");              将s3初始化一个字符串面值副本

strings4(n,'c');              将s4 初始化为字符'c'的n个副本

cin>>s5;       读取有效字符到遇到空格

getline(cin,s6);            读取字符到遇到换行,空格可读入,知道‘\n’结束(练习在下一个代码中)。

 

1.2 赋值

char *tag =“123456789”;

string str= “123”;

str.assign(10,‘c’);

str.assign(tag+1,tag+5); //两个参数a,b都是iterator,取出串[a,b)赋给str

 

1.3 读写

stringstr(“123”);

str[1] =‘b’;           访问单个字符

cout<< str[2];

str[100] = ‘a’;  //越界访问,则行为未定义。程序可能会崩溃

str.get(100)= ‘a’; //越界访问,则会抛出out_of_range类型的异常,捕获处理后,可以让

//程序不崩溃

  

1.4 长度

str.empty();    判断字符串是否为空

str.length();     获取字符串中所含字符个数

 

1.5 遍历

for(int i =0; i < str.length(); i++) {

    cout << str[i];

}

    for(string::iterator itr= str.begin(); itr != str.end(); itr++) {

        cout<< *itr;

}

 

1.6 连接

string strPre =“Mr. “;

string name =strPre + “Zhang” + “ Zhaoliang”;//string& operator+(const string& a,const char *);

//所以可以字符串连起来+,因为当前两个中有一个是string时,+返回的仍然是string&。

//但是“ABC” + “123”是错的,因为没有定义操作符char*加char*

         name.append(“123”);//效果等同于name+=”123”;

1.7 字符判断

   isalnum(c)  如果c是字母或数字,返回 true

   isalpha(c)  如果c是字母,返回true

    isdigit(c)  如果c是数字,返回true

   islower(c)  如果c是小写字母,则为true

   isupper(c)  如果c是大写字符,则为true

   tolower(c) 如果c是大写字符,则返回其小写字母,否则直接返回c

toupper(c)  跟tolower相反

 

1.8 查找

l 查找完全匹配的字符串

string str = “hellokitty”;

3种查找目标,char, string, char*

str.find(‘e’);                                   

str.find(str2);

str.find(“lo”);

以上是从字符串的头开始找,如果从ind处开始查找,其中,ind = [0,…,length -1]。则可以在后面加一个位置参数。

str.find(‘e’,ind);

str.find(str2,ind);

str.find(“lo”,ind);

所有形式的find函数的返回值语义一致。查找匹配时,返回字符或字符串首次出现的位置的index。无匹配内容时,返回string::npos值。

string name(“abcd1234”);

string::size_typeidx = name.find('d', 6);

if(string::npos == idx) {

          cout << "Not Found!"<< endl;

} else {

          cout << "index:"<< idx << endl;

}

l 查找字符串中的任一字符

stringstr=”Hello! Kitty.Well. This is is John,”

int ind = str.find_first_of(“!.”);

查找str中!、空格、.任一字符出现的第一个位置。结果是!先出现,返回5。如果是从位置10开始查找,则写成str.find_first_of(“! .”,10);

int ind =str.find_last_of(“! .”);

查找str中!、空格、.任一字符出现的最后一个位置。结果是!先出现,返回29。如果是从位置15开始向前查找,则写成str.find_last_of(“! .”, 15);

如果未找到,都是返回string::npos。

find_first_not_of,find_last_not_of是查找不在字符串中的字符,参数与find_first_of,find_last_of一样。

实现trim功能:

string s(“ \tabc \n  “);

s =s.substr(s.find_first_not_of(‘));

1.9 插入

string str1 =“abcdefgh”;

str.insert(5,“abcdefgh”);  //插入串“abcdefgh”

 

str.insert(5, str1);       //插入串“abcdefgh”

str.insert(5, “abcdefgh”,3);//插入串“abcdefgh”的前3个字符

str.insert(5, str1,3);   //插入串“abcdefgh”的前3个字符

1.10  删除

str.erase(3);//删除位置3的字符

str.erase(3,5);//删除位置3开始的5个字符

str.clear();//删除所有字符,length变成0

1.11  替换

str.replace (3,3 ,"good");//替换位置3开始的3个字符为good

str.swap(str2);//str和str2交换内容

1.12  串比较

str.compare (" good " ) ;  s与”good“比较相等返回0,比"good"大返回1,小则返回-1;

str1 < str2; //字符串比较操作符==    !=    <=  >   >=

                   “abc” < “abcde”, “abc” <“abd”

1.13  取子串

str.substr(2,4);//取位置2开始的4个字符,组成子串返回

1.14  与char*互转

string转[const] char*

string s ="abcdeg";

const char *k2= s1.c_str();//将内容转成const char*

const char*k2 =s1.data(); //将内容转成const char*

 

char k2[40];

s1.copy(k2,s.length(),0);//0是源串中的偏移量

char*转string

string str;

charchArr[]=”1234”;

str = “abcdef”;

str = chArr;

 

注意:只有c_str()在产生的字符串尾部加\0,data(), copy()函数都不会加。

1.15  与数值互转

    数值转字符串

double price =1.234;

ostringstream o;

o << price;

string str = o.str();

 

字符串转数值

string strPrice = "1.234";

string strNum = "12";

const char* ch = strPrice.c_str();

const char* ch2 = strNum.c_str();

double p = atof(ch); //若格式不正确,则返回0

int num = atoi(ch2); //若格式不正确,则返回0

[南大ICS-PA2]PA2 - 简单复杂的机器:冯诺依曼计算机系统 mips32和riscv32的指令长度只有32位, 因此它们不能像x86那样, 把C代码中的32位常数直接编码到一条指令中. 思考一下, mips32和riscv32应该如何解决这个问题?加载立即数到寄存器的高20位,然后便可以是哟给你标准的立即指令来创建32位常量。在程序分析领域中,静态指令是指程序代码中的指令,动态指令是指程序运行过程中的指令,例如对于一下指令序列。位域,在小端机器上,先定义的在每个字节的低位,后定义的在每个字节的高位。,这是处理非法指令的宏,其定义在。指令,而下一条动态指令则是。 阅读详情

相关推荐

硬件手册——PT100精密测温电路

PT100精密测温电路 一、需求分析 根据题目要求为:测温范围为0-100℃、测温精度要求为±1℃。由于铂电阻具有精度高、性能可靠、稳定性好的特点,且铂电阻的电阻相对变化率与温度的关系曲线线性度最好,故选择铂电阻作为敏感元件。而在国标中,铂电阻有几种不同的标准,如PT100、PT1000。分别对应着0摄氏度下铂电阻的阻值为100R和1000R,由于需要考虑铂电阻的自发热问题,所以尽量选择阻值小的铂电阻,故选择PT100为最终型号。 二、电路设计 2.1 热电阻接法 热电阻测温电路有多种接法,其中三线制会导致

weixin_41655430的博客 5万+

C++中string没有结束符和C语言中string的结束符‘\0‘的差异

今天遇到一个搞笑的问题,我有一个string a是读取xml文件获得的const char *之后转换成string得到的,还有一个别人传过来的string b。这俩string的内容打印出来是一模一样的,但是用string的compare()函数比较,就是不相等。后面又使用length()和size()函数看了一下,我本地的字符串a的长度总是比别人传过来的字符串长度小1。然后我将a和b逐个字符打印(按照%d)出来发现b比a多了一个字符‘\0’,对应的十进制就是0. 这个给我们造成了疑惑,我们觉得stri

jinking01的专栏 8943

泛微OA E9文档管理优化:临时文件清理与存储配置指南

本文深入解析了泛微OA E9系统性能下降的常见原因——临时文件堆积,并提供了完整的优化配置指南。文章详细介绍了临时文件的产生机制,并手把手指导管理员如何通过修改存储路径、调整保留时间、设置白名单等关键配置,有效清理与管理系统临时文件,从而释放存储空间,提升系统运行效率与稳定性。

tree8的博客 438

【C++】string是否以'\0'结尾

我今天做leetcode题的时候发现一个趣事。一个string的对象的s的[]可以取到string的size(), 即s[s.size()]。string对象的size()本应该是这个对象的大小,这个对象的区间范围应该是[0,size()-1]才对, 为什么这个对象可以取到 s[s.size()]。并且没有报错。我百思不得其解。 我本来以为string不是以’\0’结尾的,是因为string类的对...

进阶之路 4336

【Halcon-1D测量】measure_pairs 函数功能(用于提取垂直于矩形/环形弧主轴的直边对)

HALCON算子measure_pairs是1D测量模块的基础工具,专用于提取垂直于矩形/环形弧主轴的直边对。该算子通过振幅阈值和灰度过渡规则(如positive/negative)进行边对分组,支持_strongest后缀选择最强边缘避免误配对。输出包含边缘坐标、振幅及内外间距(IntraDistance/InterDistance)。关键限制包括仅适用于直边、Sigma需≤0.5×测量长度,且忽略图像域。相比模糊版本算子,它更适用于边缘清晰的简单场景(如电子元件间距测量)。典型应用需配合gen_meas

weixin_45590420的博客 307

RK3588 DDR5 方案

RK3588 DDR5方案支持多种LPDDR5/LPDDR5X内存型号,包括美光、三星、海力士、江波龙和佰维等品牌。文档详细列出了已验证的DDR5内存规格,涵盖2GB-16GB容量范围,提供组织形式、封装类型和测试状态等信息。其中美光型号最全面,支持12GB/16GB大容量方案。部分型号处于测试验证阶段(T/A),需量产进一步确认性能。该方案为RK3588平台开发提供可靠的内存选型参考。

501846585_QQAndroid_java 1105

C++ string详解,C++字符串详解

string是C++标准库的一个重要的部分,主要用于字符串处理。可以使用输入输出流方式直接进行string操作,也可以通过文件等手段进行string操作。同时,C++的算法库对string类也有着很好的支持,并且string类还和c语言的字符串之间有着良好的接口。使用 string 类需要包含头文件2.定义 string 变量string s1;//获取字符串长度return 0;}变量 s1 只是定义但没有初始化,编译器会将默认值赋给 s1,默认值是"",也即空字符串。

蜗牛的专栏 3381

Simulink仿真状态空间中状态变量时域响应

起因 今天老师留了一道关于状态空间变量响应的题,于是想用simulink仿真,一开始使用state-space模块,但是发现它只能输出y,没办法显示状态变量的变化情况。然而状态变量之间的关系都可以表示为一阶微分方程组,因此我们考虑在Simulink中搭建微分方程组来求解这个问题。 微分方程组 x1˙=x2x2˙=−4x1−5x2+1(1)\dot{x_1}=x_2\\ \dot{x_2}=-4x_...

ZYunfei的博客 7495

关于string类对象不是以空字符标记字符串末尾的探究

关于string类对象不是以空字符标记字符串末尾的探究

RonnilyChao的博客 1909

01-诊断开发流程概述

传送门 ==>> AutoSAR入门和实战系列总目录。

1789

(5)ModalAI VOXL2

Ardupilot官网关于《Non-GPS navigation》的翻译 —《(5) ModalAI VOXL2》。

无人机开发(开源Ardupilot) 1万+

C++ string类中的空字符

在做leetcode时发现一个问题。 题目如下:题目地址 题目不难,很容易做出来。 问题出现在自己写的代码里,代码如下: class Solution { public: vector<vector<int>> largeGroupPositions(string s) { vector<vector<int>> result; vector<int> tmp(2, 0); int i =

inoobkk的博客 2509

LFI Scanner 本地文件包含漏洞扫描、文件路径遍历、敏感文件读取(etcpasswd)

✅ **敏感文件读取验证**:内置`/etc/passwd、/windows/system32/drivers/etc/hosts、phpinfo.php`等敏感文件字典,一键验证漏洞可利用性;🔴 **Windows**:`/windows/win.ini`(系统配置)、`/windows/system32/drivers/etc/hosts`;🔴 **Linux**:`/etc/passwd`(用户信息)、`/proc/version`(内核版本)、`/etc/hosts`(域名解析);

寒寒豆豆软件公司的博客 134

C++ STL string字符串详解和使用方法

头文件<string> … 操作 … string操作的实参 … 构造函数和析构函数 注意: 你不能以一个单字符初始化某字符串,但是可以这样做: string a('a');//错误 string b(1, 'a');//正确 string c({ 'a' });//正确 表示存在一个从const char* 到string的自动类型转换,但不存在一个从char到s...

qq_44800780的博客 2814

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

C++STL中string头文件的各种函数以及使用方法与细节

字符串拼接:在竞赛中,频繁使用或append进行字符串拼接,但注意可能会因为临时对象的创建而导致性能下降。字符串输入输出:使用cin >>读取单词,读取整行。字符串长度:使用size()或length()获取字符串长度,两者等价。字符串比较string重载了比较运算符,可以用于排序。字符串查找和替换find和substr常用于处理子串问题,replace用于替换操作。性能考虑:对于大量字符串操作,考虑使用reserve避免不必要的内存分配。以上是string。

2301_80215285的博客 1184

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

C++第五讲(1):STL--string--各个函数的使用方法

C++第五讲(1):STL--string--各个函数的使用方法

2301_79761834的博客 1386

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

【C++STL详解(一)string使用方法】

string();//构造一个空字符串//拷贝str//从pos位置开始取len个字符拷贝//复制s所指的字符序列//复制s所指的字符序列前n个//生成n个c字符构成的字符串//迭代区间构造string s1;//构造空字符串//复制"hello string"//复制"hello string"的前3个字符//生成10个's'字符的字符串//生成s2的复制品//复制s2中从字符位置0开始并跨越4个字符的部分//通过迭代区间构造string```cpp。

2301_76560014的博客 1078

C++STL(string介绍+使用方法)

接下来我会为大家讲解C++非常厉害非常有用的一部分,也就是STL。

2201_75537973的博客 787

c++ string STL 使用方法

c++ string STL 使用方法

m0_50564748的博客 402

C++ STL 迭代器在string类中的使用方法

//以下例子说明迭代器在string类中的使用方法 #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;algorithm&gt; using namespace std; int main() { string s("Hello World! I love programming!"); cout&lt;...

Ibelievesunshine的博客 3914

C++ STL String 常规使用方法

构造函数有多个 string s1(); s1="" string s2("hello"); s2="hello" string s3(4,'a'); s3="aaaa" string s4("abcdef",1,3); s4="bcd"; 成员函数assign()和构造函数类似 求长度size() string对象的比较支持> = !=等 compare比较返回<0 ==0 >0 分别表示小于 等于 大于 .

qq_44443766的博客 181

c++使用 STL string 实现split,trim和replace方法

c++,split,trim,replace

qq632544991p的专栏 2555

初阶C++__STL__string类(使用方法+模拟实现+测试+思路分析)

Ⅰ.string类的常用接口 string库函数中的构造 补充:拷贝构造支持从pos开始,初始化npos个字符 Ⅱ.sting类对象的容量操作 1、size()与length()的区别 2、返回空间总大小的 capacity() 3、清空有效字符的 clear() 4、 调整字符串大小resize() 5、请求更改容量reserve() Ⅲ.string类对象的访问及遍历操作 1、访问字符串字符的 operator[] 和 at() 2、初识迭代器与begin() ...

qq_61386381的博客 1157

初阶C++——STL——string类、vector类和list类(使用方法+模拟实现+测试+思路分析)

从今天开始,我们正式进入STL的学习。 我们今天会重点讲解三个类——string vector 和 list 在介绍之前,我们可以先来了解一下,何为STL?以及它的优势和缺陷。

jxwd的博客 4992

STL 容器详解——string 类

带你一命通关C++的STL容器 十分钟手撕 string 类

qq_61500888的博客 3680

【C++】简述STL——string类的使用

STL的简介及string常用接口的使用

weixin_60478154的博客 1982
上一篇: C++ STL的线程安全性
下一篇: C++ STL中set和multiset的使用方法
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址