Coupon Accepted Successfully!



1. A string is nothing but a sequence of characters. They are declared as a character array. Each element of the string occupies a byte in the memory. Every string is terminated by a null character.

2. To make the string manipulation easy, the ANSI committee added a new class called string. It allows us to define objects of a string type, and they can be used as a built-in data type. The string class is considered another container class and not a part of STL (standard template library).

3. Two string objects can be concatenated using overloaded + operator. The overloaded += operator appends one string to the end of another string. The operators << and >> are overloaded operators, and they can be used for input and output operations.

4. Table 18.4 describes various relational operators. These operators can be used with string objects for assignment, comparison, and so on.

5. The member functions insert(), replace(), erase(), and append() are used to modify the string contents.

6. The various attributes of the string such as size, length, and capacity can be obtained using member functions. The size of the string indicates the total number of elements currently stored in the string. The capacity means the total number of elements that can be stored in the string. The maximum size means the largest valid size of the string supported by the system.

7. It is possible to access a particular word or a single character of the string with the help of member functions of the string class, such as at(), find(), substr(), find_first_of(), and find_last_of().

8. The string class contains functions that enable the programmer to compare and exchange the strings. These functions are swap() and compare().

Test Your Skills Now!
Take a Quiz now
Reviewer Name