Coupon Accepted Successfully!


Moving From C String To C++ String

In the last few examples, we have observed that a string is nothing but a sequence of characters, and it is declared as a character array. However, the manipulation of a string in the form of a character array requires more effort. C uses a library function defined in string.h to carry out string manipulation.

To make the string manipulation easy, the ANSI committee added a new class called a string. It allows us to define objects of the 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). The programmer should include the string header file.

Instead of declaring a character array, an object of the string class is defined. Using the ­member function of the string class, string operations such as coping, comparison, and concatenation are carried out more easily as compared with C library functions.

The string class is very vast. It also contains several constructors, member functions, and operators. These constructors, member functions, and operators help us perform various operations with strings.

Test Your Skills Now!
Take a Quiz now
Reviewer Name