- C 标准库
- C 标准库
- C++ 标准库
- C++ 库 - 主页
- C++ 库 - <fstream>
- C++ 库 - <iomanip>
- C++ 库 - <ios>
- C++ 库 - <iosfwd>
- C++ 库 - <iostream>
- C++ 库 - <istream>
- C++ 库 - <ostream>
- C++ 库 - <sstream>
- C++ 库 - <streambuf>
- C++ 库 - <原子>
- C++ 库 - <复杂>
- C++ 库 - <异常>
- C++ 库 - <功能>
- C++ 库 - <限制>
- C++ 库 - <语言环境>
- C++ 库 - <内存>
- C++ 库 - <新>
- C++ 库 - <数字>
- C++ 库 - <正则表达式>
- C++ 库 - <stdexcept>
- C++ 库 - <字符串>
- C++ 库 - <线程>
- C++ 库 - <元组>
- C++ 库 - <类型信息>
- C++ 库 - <实用程序>
- C++ 库 - <valarray>
C++ 字符串库 - Push_back
描述
它将字符 c 添加到字符串末尾,将其长度增加一。
宣言
以下是 std::string::push_back 的声明。
void push_back (char c);
C++11
void push_back (char c);
C++14
void push_back (char c);
参数
c - 它是一个字符对象。
返回值
没有任何
例外情况
如果抛出异常,则字符串不会发生任何变化。
例子
在下面的 std::string::push_back 示例中。
#include <iostream>
#include <fstream>
#include <string>
int main () {
std::string str;
std::ifstream file ("sample.txt",std::ios::in);
if (file) {
while (!file.eof()) str.push_back(file.get());
}
std::cout << str << '\n';
return 0;
}
字符串.htm