代码点读机 / C++ / string

string C++ · 头文件

C++ 字符串类头文件,提供 std::string,比 C 风格 char[] 更安全、更方便。

怎么用

#include <string>

小例子

#include <string>
std::string s = "hello";
s += " world";
std::cout << s;

运行结果

hello world

提醒:string 自动管理内存,支持 +、+=、==、< 等运算符

官方文档:https://en.cppreference.com/w/cpp/header/string

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C++全部词条