How to use the string type in C++
This article mainly explains "how to use the string type in C++". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the string type in C++".
1. Similarities and differences between string class 1.1 and char *
In C++, in addition to the char * type, there is a special string type, which is called string.
By including the header file string, you can use:
Include
In many ways, the string type is used in the same way as char *, for example:
String str1;string str2 = "hello world"; / / initialization and char * consistent cout