最适合网络开发者的网站
C++ 语言。W3Schools 英文版。初学者课程

尿素 西斯

C++ String Data Types


String Types

The string type is used to store a sequence of characters (text). This is not a built-in type, but it behaves like one in its most basic usage. String values must be surrounded by double quotes:

例子

string greeting = "Hello";
cout << greeting;

To use strings, you must include an additional header file in the source code, the <string> library:

例子

// Include the string library
#include <string>

// Create a string variable
string greeting = "Hello";

// Output string value
cout << greeting;
亲自尝试 »

You will learn more about strings, in our C++ 字符串 chapter.



评论