string的基本操作

String基本操作详解 以上就是String类基本操作的详细介绍和相应的代码示例。通过这些基本操作,我们可以对字符串进行创建、获取长度、连接、截取、查找、替换、分割和转换等操作,使得我们可以更灵活地处理字符串数据。希望本文对你理解和应用String类有所帮助。如有任何疑问,请随时提问。String是Java中常用的字符串类,它提供了一系列用于操作字符串的方法。本文将详细介绍String类的基本操作,并提供相应的代码示例。这两种方式创建的字符串对象在内存中都会有一个对应的String实例,可以进行后续的操作。字符串的长度为:13。 阅读详情

string


string 字符串其实是一种更加高级的封装,string字符串中包含大量的方法,这些方法使得字符串的操作变得更加简单

在C++中将字符串直接作为一种类型,也就是string类型,使用string类型创建的对象就是C++的字符串

注意: 使用C++中提供的string时, 必须添加头文件

string s1; 
string s2 = "hello, world"; 

也可以用其他方式初始化 ,

string s3("hello, world"); 

注意:这种方式只能是初始化,不能用于后赋值

string s3; 
s3("hello, world");  // error

string 类型可以直接赋值

例如:

s2 = "abc"; 
s3 = "hello, world"; 
s2 = s3; // 赋值
cout << "s2: " << s2 << endl; // hello world

可以用 ‘+’来拼接两个字符串

    string s1 = "hello, "; 
    string s2 = "world!";
    string s3 = s1 + s2; 
    cout << s3 << endl;   // hello, world!

没有‘-’操作

    string s1 = "hello, world"; 
    string s2("world"); 
    string s3 = s1 - s2; // error: 不支持减法操作
    cout << "s3: " << s3 << endl;

string字符串的输入

cin的方式

可以直接使用cin 给 string类型的字符串中输入一个字符串的数据

    string s1; 
    cin >> s1;  // hello world
    cout << "s1: " << s1 << endl; // s1: hello  不能读取空格后的内容

getline的方式

getline是C++标准库中的一个函数,用于从输入流中读取一行文本,并i将其存储为字符串

getline函数有两种不同的形式,分别对应着字符串的结束方式.

istream getline (istream is, string str); 

istream getline (istream is, string str, char deline); 

istream 是输入流类型, cin 是 istream 类型的标准输入流对象

ostream 是输出流类型, cout 是ostream 类型的标准输出流对象

getline 函数是输入流中读取一行文本信息,所有如果是在标准输入流(键盘)中读取数据,就可以传 cin 给第一个参数

第一种 getline 函数是以换行符‘\n’作为字符串的结束标志,它的一般格式是

getline (cin, string str);  
// cin -- 表示从输入流中读取数据 
// str -- 是存放读取的信息的字符串
    string s1; 
    getline(cin, s1); // hello world
    cout << "s1: " << s1 << endl; // s1: hello world

这种形式的getline 函数从输入流(例如cin)中读取文本,直到遇到换行符(‘\n’)为止,然后将读取的文本(不包括换行符)存储到string 类型的变量 str 中

第二种 getline 函数允许用户自定义结束标志,它的一般格式是 :

getline (cin, string str, char deline); 

这种形式的getline 函数从输入流(例如cin)中读取文本,直到遇到用户指定的结束字符(deline)为止,然后将读取的文本(不包括结束标志字符)存储到string 类型的变量 str 中

    string s1; 
    getline(cin, s1, 'r');  // hello world
    cout << "s1: " << s1 << endl; // s1: hello wo

size()

string 中提供了 size() 函数用于获取字符串长度

在C++中关于字符串的操作函数都是包含在string 中的,所有需要调用这些函数的时候, 通常需要用.点运算符

    string s1; 
    string s2 = "hello"; 
    string s3 = "abc      123"; 
    cout << s1.size() << endl;  // 0
    cout << s2.size() << endl;  // 5
    cout << s3.size() << endl;  // 11
    string str1; 
    cin >> str1; 
    cout << str1 << endl;  // hello
    cout << str1.size() << endl; // 5

​ string 类型字符串也是有下标的,下标从0开始

逐个打印字符串中的字符

    string str = "hello world";
    cout << str << endl;  // hello world
    int sz = str.size(); 
    for (int i = 0; i < sz; i++) {
        cout << str[i] << " "; // h e l l o   w o r l d
    } 

迭代器(iterator)

迭代器是一种对象,他可以用来遍历容器, (比如string)中的元素,迭代器的作用类似于指针或者数组下标

访问迭代器指向的值,需要解引用(*);

begin() 和 end()

begin(): 返回指向字符串第一个字符的迭代器,需要一个迭代器的变量来接收

end(): 返回指向字符串最后一个字符的下一个位置的迭代器 (改位置不属于字符串).

string中begin() 和 end() 返回的迭代器的类型是 string::inerator

迭代器是可以进行大小比较,也可以进行‘+’或者‘-’整数运算的

比如it++, 就是让迭代器前进一步,it–就是让迭代器退后一步

同一个容器的两个迭代器也可以相减,相减结果的绝对值,是两个迭代器中间元素的个数

    string str = "abcdef"; 
    string::iterator it1 = str.begin();   
    string::iterator it2 = str.end();  
    int n = it1 - it2; 
    cout << n << endl;  // -6

比较大小

   // 比较大小
    if(it1 < it2) {
        cout << "it1 小于 it2" << endl; 
    }
        
    else {
        cout << "it1 不小于 it2" << endl;
    }

解引用操作

// 解引用操作
cout << *it1 << endl;  // a

遍历

    for (string::iterator it1 = str.begin(); it1 < str.end(); it1++) {
        cout << *it1 << " ";  
    } // a b c d e f

倒序遍历

    // 倒序遍历
    for (auto it2 = str.end(); it2 >= it1; it2--) {
        cout << *it2 << " "; 
    }   // f e d c b a

字符串中的+= 和+运算

string 类型的字符是支持+ 和 +=运算的,这里的本质是string中重载了operator这个操作符

    string s1 = "Hello ";
    string s2 = "World";
    s1 += s2; // 使用 += 运算符连接字符串
    cout << "使用 += 运算符连接字符串: " << s1 << endl;
    cout << s1 + "world" << endl; // 使用 + 运算符连接字符串字面值
    string  s3 = s1 + s2;
    cout << s3 << endl;         // 使用 + 运算符连接两个字符串对象

push_back

用于在字符串尾部插入一个字符

    string s = "abc "; 
    s.push_back('h'); 
    s.push_back('e'); 
    s.push_back('l');                   
    s.push_back('l');
    s.push_back('o'); 
	cout << s << endl; //abc hello

连续插入

    string str; 
    char c = 0; 
    for (c = 'a'; c <= 'z'; c++) {
        str.push_back(c); 
    }
    cout << str << endl;  // abcdefghijklmnopqrstuvwxyz

pop_back()

用于删除字符串中尾部的一个字符

    string str = "hello world";
    str.pop_back(); 
    cout << str << endl; //hello worl

当字符串为空时再去调用pop_back是标准未定义的行为

循环删除字符串的元素

	string str = "hello world"; 
	int sz = str.size(); 
	while (sz >= 2 ) {
		
		str.pop_back(); 
		sz--;  
	}  
	cout << str << endl; // h
	cout << sz << endl;  // 1

insert


在字符中的某个中间的某个位置插入一个字符串

string insert ( size_t pos, const string& str); // pos位置前面插入一个string字符串
string insert ( size_t pos, const char* s);  	// pos位置前面插入一个c风格的字符串
string insert ( size_t pos, size_t t, char c); 	// pos位置前面插入n个字符c
    string str1 = "hello world"; 
    string str2 = "xxx"; 
    str1.insert(5, str2);
    cout << str1 << endl; //helloxxx world
    string str1 = "hello world"; 
    char str2[] = "yyy"; 
    str1.insert(5, str2);
    cout << str1 << endl; //helloyyy world
    string str1 = "hello world";
    str1.insert(4, 3, 'x'); 
    cout << str1 << endl; // hellxxxo world

find

finf() 函数用于查找字符串中指定子串/字符,并返回子串/字符在字符串中第一次出现的位置

size_t find ( const string& str, size_t pos = 0) const;  // 查找string类型的字符串str, 默认是从头开始,pos可以指定位置开始
size_t find ( const char* s, size_t pos = 0) const; // 查找c风格的字符串s,默认是从头开始,pos可以指定位置开始 
size_t find (const char* s, size_t pos, size_t n) const;  // 在字符串的pos位置开始查找c风格的字符串s中的前n个字符
size_t find ( char c, size_t pos = 0) coust; 	// 查找字符,默认从头开始,pos可以指定位置开始

返回值;

若找到,返回子串/字符在字符串中第一次出现的起始下标位置

若未找到,返回一个整数值npos,通过判断find()函数的返回值是否等于npos就能知道是否查找到子串或者字符

注意: 即使指定起始位置不是开头,返回的下标是相对于起始位置而言的

    string s = "hello world hello everyone"; 
    string str = "llo"; 
    size_t n = s.find(str); 
    cout << n << endl; //2

从上次找到的位置接着查找

    string s = "hello world hello everyone"; 
    string str = "llo"; 
    size_t n = s.find(str); 
    cout << n << endl; //2

    n = s.find(str, n + 1); 
    cout << n << endl; // 14

也可以使用C风格的字符串

    string s = "hello world hello everyone"; 
    size_t n = s.find("llo"); 
    cout << n << endl; //2

    n = s.find("llo", n + 1); 
    cout << n << endl; // 14

在字符串的pos位置开始查找c风格的字符串s中的前n个字符

    string s = "hello world hello everyone"; 
    size_t n = s.find("word", 0, 3); 
    cout << n << endl;  //6

也可以在当前位置接着查找

    string s = "hello world hello everyone"; 
    size_t n = s.find("word", 0, 3); 
    cout << n << endl;  //6
    size_t m = s.find("everyone", n + 1, 4);
    cout << m << endl;  //18
//size_t find(const char* s, size_t pos, size_t n) const;  // 注意:这个只能用于char*,不能用于string!

    string s = "hello world hello everyone"; 
    string str = "llo"; 
    char ch[] = "llo"; 
    size_t n = s.find(str, 0, 3);   //error 要查找字符串前n个字符, 只能用于char*类型 不能用于string类型
    cout << n << endl;  
    size_t m = s.find(ch, 0, 3);    // right
    cout << m << endl;  

也可以用find()查找单个字符

    string s = "hello world hello everyone"; 
    size_t n = s.find('o'); 
    cout << n << endl;  //4 

要找字符下一个出现的位置,要从当前位置的一个位置开始查找

    n = s.find('o', n + 1); 
    cout << n << endl;  //7

没有找到

    string s = "hello world hello everyone"; 
    string str = "xyz"; 
    size_t n = s.find(str); 
    cout << n << endl;  //18446744073709551615 string::npos 返回-1, 表示未找到,被当作无符号整数最大值处理 
    cout << string::npos << endl; //18446744073709551615

判断是否找到

    string s = "hello world hello everyone"; 
    string str = "xyz"; 
    size_t n = s.find(str); 
    cout << n << endl;  //18446744073709551615 string::npos 返回-1, 表示未找到,被当作无符号整数最大值处理
    if (n == string::npos) {
        cout << "找不到" << endl;
    } else {
        cout << "找到了" << endl;
    }

substr()

substr() 函数用于截取字符串中指定位置指定长度的子串,

string substr ( size_t pos = 0; size_t len = npos) coust; 
// pos 的默认值是0, 也就是从下标0的位置开始读取
// len 的默认值是npos,意思是一直截取到字符串的末尾

substr():如果函数不传参,就是从下标为0的位置开始截取,知道结尾,得到的是整个字符串

substr(pos):从指定下标pos位置开始截取子串,知道结尾

substr(pos, len):从指定下标pos位置开始截取长度为len的子串

   string str = "hello world hello everyone";
   string s = str.substr(3, 6); 
   cout << s << endl; // lo wor
    string str = "hello world hello everyone";
    string s1 = str.substr(3, 6); 
    cout << s1 << endl; // lo wor
     
    string s2 = str.substr(7); 
    cout << s2 << endl; // rld hello everyone 

    string s3 = str.substr(); 
    cout << s3 << endl; // hello world hello everyone 

substr() 和 find() 经常是配合使用的,find负责找到位置,substr() 从这个位置向后获得获得字符串

注意需要包含头文件

    string str = "hello world hello everyone";
    size_t n =str.find("world");
    string s1 = str.substr(n, 10); 
    cout << s1 << endl; //world hell

compare() 字符串比较

字符串比较是按照字符的ASCLL码进行对比

= 返回 0

> 返回 1

< 返回 -1

函数原型:

  • int compare(const string &s) const; 
    int conpare(const char* s) const; 
    
int test01() {
	string str1("hello"); 
	string str2("xello"); 
	if (str1.compare(str2) == 0) {
		cout << "str1 等于 str2" << endl; 
	}  else if (str1.compare(str2) < 0) {
		cout << "str1 小于 str2" << endl; 
	} else {
		cout << "str1 大于 str2" << endl; 
	} 
}
int main() {
	test01();  
	// str1 小于 str2
	return 0; 
} 

字符串的存取

获取字符有两种方法

  • char& operator[](int n) 通过[ ] 的方式获取
  • char& at(int n) 通过at 的方式获取字符

方法一 通过[]的方式获取

void test01() {
    string str("helle"); 
    for (int i = 0; i < str.size(); i++) {
        cout << str[i] << " "; 
    } 
    cout << endl; 
}

方法二 通过at的方式获取

void test02() {
    string str("helle"); 
    for (int i = 0; i < str.size(); i++) {
        cout << str.at(i) << " "; 
    } 
    cout << endl; 
} 

string的关系运算

string类型是C++中封装类型也就是非内置类型,需要让他忙也支持关系运算,这里就涉及到运算符的重载,这些重载就使得string的字符也可以支持关系运算

    // s1 == s2; 
    s1 == s2;  
    bool operator== (const string& lhs, const string& rhs); // 使用方式 s1 == s2
    bool operator== (const char*   lhs, const string& rhs); // 使用方式 s1 == s2
    bool operator== (const string& lhs, const char*   rhs); // 使用方式 s1 == s2
    // 不能使用  bool operator== (const char*   lhs, const char*   rhs); // 使用方式 s1 == s2
    // 无法比较两个c风格字符串是否相等

无法比较两个c风格字符串是否相等

其他运算符同理

字符串的比较是基于字典序进行的,比较的是对应位置上的字符的ASCLL值的大小,比较的不是字符串的长度

    "abc" < "aq" ; // 'b' 的ASCLLI值小于 'q' 的ASCII值, 所以返回true
    "abxdef" < "ff" // 'a' 的ASCII值小于 'f' 的ASCII值, 所以返回true
    "100" < "9" // '1' 的ASCII值小于 '9' 的ASCII值, 所以返回true
    

string相关的函数

stoi 和 stol

stoi 是将字符串转换成int 类型的值

stol 是将字符串转换成long int 类型的值

stoi 和 stol 非常类似

stoi 函数其实可以将一个string类型的字符串,转换为整型,

int stoi (const strinf& str, size_t* idx = 0; int base = 10); 
long int (const string& str, size_t* idx = 0; int base = 10); 
  • str – 表示被转换的string类型的字符串
  • idx 是一个输出型函数,也就是这个通过这个参数会带回一个值,idx 是一个指针,需要在外边创建一个size_t类型的值,传递它的地址给idx ,这个参数会带回str中无法正常匹配数字的第一个字符的位置
  • base 表示被解析的字符串中数字的进制位,可能是2, 8, 10, 16或者0 也可以自定义进制
    • 默认情况下这个值是10, 表示10进制数字
    • 如果传递的是2, 表示被解析的字符串是2进制的数字,最终会转换成10进制
    • 如果传递的是8, 表示被解析的字符串是8进制的数字,最终会转换成10进制
    • 如果传递的是16, 表示被解析的字符串是16进制的数字,最终会转换成10进制
    • 如果传递的值是0, 会根据字符串的内容的信息自动推导进制,
      • 比如:字符串中有0x,就认为是16进制
      • 0开头会被认为是8进制,最终转换成10进制
    string str = "11x123";   
    size_t idx = 0; 
    int n = stoi(str, &idx); // 第三个参数不写则默认按十进制转换 
    cout << "n = " << n << endl;  // n = 11
    cout << "idx = " << idx << endl;  // idx = 2 第一个非数字字符的位置 

    n = stoi(str, &idx, 16); // 按十六进制转换
    cout << "n = " << n << endl;  // n = 17

    n = stoi(str, &idx, 6); // 按六进制转换
    cout << "n = " << n << endl;  // n = 7

如果不想要第二个参数,也可以直接传递NULL;

    string str = "3.14159abc";
    int n = stoi(str, NULL); 
    cout << "n = " << n << endl;  // n = 3

stof 和 stod

stod 是将字符串转换成double类型的值,函数原型如下,和stoi函数比较的话,少了描述字符串中数字进制的参数,其他参数一致,stof是将字符串转换成float类型的值

double stod (const string str, size_t* idx = 0); 
float stof (const string str, size_t* idx = 0); 
    string str = "3.14acb145";  
    size_t idx = 0;  
    double m = stod(str, &idx); 
    cout << "m = " << m << endl;  // m = 3. 14
    cout << "idx = " << idx << endl;  // idx = 4

也可以直接传递NULL

    double n = stod(str, NULL); 
    cout << "n = " << n << endl;  // n = 3.14 

to_string


string to_string(intval);
string to_string (long val);
string to_string (long long val);
string o_string(unsignedval);
string to_string (unsigned long val);
string to_string (unsigned long long val);
string to_string (float val);
string to_string (double val);
string o_string (long double val);

to_string 函数可以将数字转换成字符串,从上述函数原型的角度看,可以将整型,浮点型转换成字符串型

    int n = 155; 
    string str = to_string(n); 
    cout << "str = " << str << endl;  // str = 155

    double m = 3.14; 
    string str2 = to_string(m); 
    cout << "str2 = " << str2 << endl;  // str2 = 3.140000
YOLOv8 轴承缺陷检测 使用YOLOv8进行训练、评估和可视化预测结果 包含1440张图片的轴承缺陷检测数据集 YOLO格式或XML格式 本文介绍了一个基于YOLOv8的轴承缺陷检测项目。数据集包含1440张图片,标注了4类缺陷(凹槽、凹陷、卡伤、划痕),按8:1:1比例划分为训练集(1152张)、验证集(144张)和测试集(144张)。标注文件支持YOLO格式和XML格式,可直接用于模型训练。项目实现了数据准备、模型训练、评估及可视化预测结果的全流程,使用YOLOv8n预训练模型进行50个epoch的训练,并提供了数据格式转换(XML转YOLO)的代码示例。最终模型可自动检测轴承表面缺陷,并保存预测结果。 阅读详情

相关推荐

上证指数30年k线图_金融占星简单解读上证指数30年历史行情

阅读此文需要一定的占星基础知识,本人对于金融知识了解甚少,如有描述错误请包涵指正!影响大众事件发展趋势的都是外行星,即木星-冥王星这5颗,由于时间跨度长达30年,绘制社会行星的K线图工作量太大,所以只以时代行星对这30年行情的简单解读作为分享,在今后的短期分析中会逐渐加入社会行星,甚至在个股分析上还会加入个人行星。那即使只绘制时代行星,所展现出来的信息也无法在一张图上画出来,否则太乱难以分辨,所以...

weixin_39831242的博客 1666

String基本操作

一、String基本操作方法 首先说一下基本操作方法,字符串的基本操作方法中包含以下几种:(1)获取字符串长度length()  (2)获取字符串中的第i个字符charAt(i)  (3)获取指定位置的字符方法getChars(4个参数) 1、 获取字符串长度方法length() 格式:int length = str.length(); 2、获取字符串中的第i个字符...

wangwangshuibingbing的博客 1182

西门子1500 PLC与巴鲁夫RFID实战:从硬件接线到数据读写的完整流程

本文详细介绍了西门子S7-1500 PLC与巴鲁夫RFID系统集成的完整实战流程。内容涵盖从硬件选型、接线、PROFINET网络配置,到在TIA Portal中安装GSD文件、组态设备、分配地址,再到使用标准功能块(如FB31)进行程序架构设计、实现数据读写以及错误诊断。文章重点分享了硬件连接要点、软件配置步骤、数据块管理技巧以及调试中常见问题的解决方案,为工业自动化工程师实施RFID项目提供了清晰的指导。

weixin_29161785的博客 380

String的基本操作

String的基本操作

xiaotai1234的博客 263

【记录】游戏体验报告怎么写(自我成长篇)

2019年3月更新: 这个倒是不用推翻,我个人虽然写的东西还是有一些偏差的,但是“表哥”说的倒是没毛病的,这篇主要是为了记录用,具体的干货也有,都在图片里,请自行提取 =====18年初原答案 作为一个游戏策划新人,游戏分析可能抓不到点子上,试着总结记录一下游戏体验报告分析的成长(因为水平不同,视野可能也不一样,也许之后几年回头看这些东西都是小儿科或者是错误的,所以只写出当下的想...

eat_human的博客 6万+

ESP-Mesh-Lite vs ESP-Mesh:如何选择适合你的物联网组网方案?

本文深入对比了乐鑫ESP-Mesh-Lite与ESP-Mesh两种物联网组网方案的核心差异。重点解析了ESP-Mesh-Lite分布式协议栈架构的优势,即每个节点拥有独立IP,可直接访问外部网络,极大简化了应用层开发。文章从网络架构、性能、开发体验及适用场景等多维度进行分析,为开发者根据项目需求(如分布式数据采集、智能家居或集中控制网络)选择最合适的方案提供了清晰的决策框架。

pluto的博客 807

string基本操作

string基本操作 1、用单双引号括起来的就叫字符串 2、创建字符串:str1 = "asdf" 3、使用"+"进行连接字符串print(str1+str2) 4、使用","进行连接字符串print(str1,str2) 5、使用"%"格式化字符串print("%%"%(str1,str2)) 6、使用join进行链接:s1 = ['hello', 'worl...

aaa496979965的博客 739

android6 usb默认文件管理,不弹RSA配对提示框

本文修改针对 高通 Android6.0.1 出user版本时 https://www.cnblogs.com/Jokeyyu/p/7424262.html http://blog.csdn.net/sinc00/article/details/44957943 diff --git a/frameworks/base/packages/SystemUI/src/com/android...

木叶风的博客 684

String类中对于字符串的基本操作

Java API 学习前提: 掌握String类和StringBuffer(字符串缓冲区)类的使用 了解System类,Runtime类,Math类和Random(随机的)类的使用 第一节-什么是API API:指应用程序编程接口。本次主要涉及的java API指的就是JDK中提供的各种功能的Java类。 String类和StringBuffer类 Java中定义这两个类来封装字符串,并提供了一系列操作字符串的方法,且由于均位于Java.lang包中,因此在使用时,无需导包。 Sting类的初始化 我们可以

d5_fengzi的博客 476

SillyTavern 向量存储配置踩坑记:从卡死到本地部署 Ollama 跑通

用此命令看到镜像就算成功。

qq_62483451的博客 1240

国内合规开通ChatGPT Plus实操指南:银行卡绑卡与支付全解析

ChatGPT Plus 是 OpenAI 官方推出的高级订阅服务,基于 GPT-4o 多模态大模型提供语音交互、图像理解与长上下文处理能力。其核心使用前提在于完成合规的国际支付绑定,而非网络接入方式。技术原理上,OpenAI 采用 Stripe 支付网关进行风控校验,重点匹配银行跨境权限、卡片类型(仅支持 Visa/Mastercard/Amex 信用卡)、BIN 号段及地理位置一致性。该机制决定了95%的绑卡失败源于银行端配置缺失或卡片不兼容,而非网络问题。实际应用中,PayPal 作为中间支付层可显著

chuannaoxuan4674的博客 1753

c++ string类基本操作

  string类的增删改查比分转     常用最基本操作   1、创建和插入 创建  string s="study hard and make progress everyday! every day!! 插入    s2.insert(positon, string);//插入位置(0开始), 插入字符串s3.append(string, startPosition,endPosi...

叔于田蒸蒸的博客 766

蓝桥杯第七届省赛试题--“模拟风扇控制系统”

题目要求 功能简述 “模拟风扇控制系统”能够模拟电风扇工作,通过按键控制风扇的转动速度和定时时间,数码管实时显示风扇的工作模式,动态倒计时显示剩余的定时时间,系统主要由数码管显示、单片机最小系统、按键输入和电机控制保护电路组成,系统框图如图 1 所示: 单总线驱动程序、CT107D 单片机考试平台电路原理图以及本题所涉及到的芯片数据手册,可参考计算机上的电子文档。程序流程图及相关工程文件请以考生...

qq_43280087的博客 2654

STL--string基本操作

回顾vector操作: #include<iostream> #include<algorithm> #include<vector> using namespace std; int main() { vector<int> v; int i,s=10; for(i=1; i<=10; i++)//加入数据 {...

weixin_44606952的博客 165

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

NTscan扫描工具

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

【C++】String类的若干基本操作

String若干基本操作

m0_57050876的博客 140

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

C++ String容器的基本操作

C++ String容器 目录C++ String容器初始化拼接查找和替换比较子串/插入和删除 初始化 string s1; //无参构造 string s2(5, 'x'); //5 个 x string s3("Hello World"); //Hello World string s4(s3); //拷贝构造 拼接 string s = "abc"; string s2 = "...

Jancoyan 472

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

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

redis基本操作——string、list、hash

redis(Remote Dictionary Server)是一个开源的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中介。应为是内存数据库,一般都是简单的存取操作,所以读取时间非常快。在linux中启动redis的命令为raw表示识别中文字符,如果不加可能会导致不识别的情况。redis中的数据都是以 key value的形式存在。redis支持丰富的数据类型:string字符串、list列表、hash散列(字典)、set集合、zset有序集合。

m0_58457640的博客 891

C++string类型基本操作

include <string>后可使用string类型。注意,不是cstring。

qq_42274004的博客 189

【Redis】String 的基本操作和场景说明

字符串的基本操作

上善若水 869

C++ 标准库类型string的初始化以及基本操作

标准库类型string表示可变长的字符序列,使用string类型必须首先包含string头文件。作为标准库的一部分,string定义在命名空间std中。 #include<string> using namespace std; //或者using std::string; 1.定义和初始化string对象 //初始化string对象的方式 string s1; ...

freeygh的博客 1904

Redis数据类型——string类型数据的基本操作

1.string类型的基本操作 2.string类型数据的扩展操作 2.1 增加和减少 2.2 控制数据的生命周期 3.string类型数据操作的注意事项

weixin_44860226的博客 194

Redis基本操作-string

Redis的5种数据结构:string、list、hash、set和zset; Redis 所有的数据结构都是以唯一的 key 字符串作为名称,然后通过这个唯一 key 值来获取相应的 value 数据。不同类型的数据结构的差异就在于 value 的结构不一样。 基本操作 1、string表示的是一个可变的字节数组; 2、Redis的字符串时动态字符串,是可以修改的; 3、内部结构实现上类...

weixin_30293135的博客 95

string 与Vector 向量变量的基本操作

stringstring是一种自定义的类型,它可以方便地执行c-串所不能直接执行的一切操作。它处理的空间占用问题是自动的,需要多少,用多少,不像字符指针那样,提心吊胆于指针脱钩时的空间游离。它可以从c-串转换得到,还可以从内部“提炼”出c串........。string本身就是针对字符串操作来设计的。例如://--------------------------------------------

PEPSI_COLA的专栏 2051

JAVA中String字符串的各种基本操作

文字引用https://blog.csdn.net/u012369373/article/details/49894551/* String类适用于描述字符串事物。 那么它就提供了多个方法对字符串进行操作。  常用的方法如下:  1、获取:  1.1 字符串中包含的字符数,也就是字符串的长度。  int length():获取长度。  1.2 根据位置获取该位置上的某个字符。  char ch...

xxl121的博客 583

Redis String 基本操作 - 2

root@yuan:/usr/local/bin# redis-cli 127.0.0.1:6379> keys * (empty array) 127.0.0.1:6379> mset k1 value1 k2 value2 k3 value3 --- 设置多个key-value的值 OK 127.0.0.1:6379> keys * 1) "k3" 2) "k1" 3) "k2" 127.0.0.1:6379> mget k1 k2 k3 --- 获取多个key-va...

ytdgh1988的博客 998

C++之string基本操作

熟悉STL里面的数据结构对我们做算法题有非常大的帮助,博主在Leetcode上做题就深感对STL的不熟练带来的尴尬,大多停留在C语言的思想做题。而熟悉STL不但可以优化算法,还可以装逼。 string类简化我们对字符串的操作,想想C语言的字符串的增删改查,一不小心就Bug了。string还封装了专门用于宽字符的wstring,操作基本都一样。 构造函数: string有重载了非常多构造函数,...

Myliang97的博客 6029
上一篇: 初识STL
下一篇: C++中vector容器的基本操作
for_ever_love__
博客等级 码龄1年 64粉丝 310原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值