Strings

So far we have discussed C++'s handling of both integer and floating-point arithmetic, and we have talked about how variables can be used to save the results of numerical expressions in memory. However, programs often have to manipulate text data. For instance, a compiler analyzes program text, and a word processor must detect the ends of words and of sentences. String literals such as “this is a string of characters” are part of the C++ language. However, C++ does not directly support character string data types. The standard C++ library has defined a type string, which is simple and intuitive to use.

The type string

The type string is not built into C++ like int or float, but it is made possible by the class mechanism of C++. Standard ...

Get C++ By Example: UnderC Learning Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.