C++ 基础笔记
来源:互联网 发布:淘宝怎么上传商品 编辑:程序博客网 时间:2024/04/23 22:50
public static member constant
std::string::npos
<string>
static const size_t npos = -1;
Maximum value for size_t
npos is a static member constant value with the greatest possible value for an element of type size_t.This value, when used as the value for a len (or sublen) parameter in string's member functions, means "until the end of the string".
As a return value, it is usually used to indicate no matches.
This constant is defined with a value of -1, which because size_t is an unsigned integral type, it is the largest possible representable value for this type.
public member function
std::string::erase
<string>
- C++98
- C++11
string& erase (size_t pos = 0, size_t len = npos);
iterator erase (const_iterator p);
iterator erase (const_iterator first, const_iterator last);
Erase characters from string
Erases part of the string, reducing its length:- (1) sequence
- Erases the portion of the string value that begins at the character position pos and spans len characters (or until the end of the string, if either the content is too short or if len is string::npos.
Notice that the default argument erases all characters in the string (like member function clear). - (2) character
- Erases the character pointed by p.
- (3) range
- Erases the sequence of characters in the range [first,last).
// string::erase#include <iostream>#include <string>int main (){ std::string str ("This is an example sentence."); std::cout << str << '\n'; // "This is an example sentence." str.erase (10,8); // ^^^^^^^^ std::cout << str << '\n'; // "This is an sentence." str.erase (str.begin()+9); // ^ std::cout << str << '\n'; // "This is a sentence." str.erase (str.begin()+5, str.end()-9); // ^^^^^ std::cout << str << '\n'; // "This sentence." return 0;}
simpio.h
GetInteger
Getread
GetLine
- C语言基础笔记
- C++Primer 笔记 -- 基础
- C基础笔记1
- C语言基础笔记
- C语言 基础笔记
- C语言基础笔记
- C语言基础笔记
- Objective-C基础笔记
- C/C++基础学习笔记
- linux c/c++基础笔记
- 类别(objective-c基础笔记)
- C语言基础学习笔记
- C语言基础概况笔记
- C基础入门笔记1
- C语言基础笔记1
- C、C++基础学习笔记
- Objective-C基础语法笔记
- Objective-C基础笔记二
- 分布式存储系统Tair之研究
- java.sql.SQLException: Connections could not be acquired from the underlying database!
- Oracle online redo log 扫盲
- jQuery基础语法笔记
- 【FireFox插件】ScrapBook:剪切簿,保存常用部分页面
- C++ 基础笔记
- 【Firefox插件】Firebug:能够调试所有网站语言
- C++字串string使用說明書
- C#扩展方法
- android进入应用程序时实现动画效果
- 2013寒假练习 1021:Pascal's Travels
- C#菜鸟之漫漫长路~~~类型转换
- <zz>Matlab内存不足问题的解决【转】
- Combobox出现System.Data.DataRowView的原因,