C++ String Data Type

In C++, the string data type is used to store text values, which consist of multiple characters. While char holds a single character, string allows working with complete words or sentences.

Tutorials dojo strip



Declaring a String Variable

A string value must be enclosed in double quotes (" ").

Example

C++




Using the <string> Library

The string type is not built-in, but it behaves like one. To use string, the <string> library must be included in the code.

Example

C++




Key Points About Strings in C++

  • Strings are enclosed in double quotes (" ").
  • Unlike char, a string stores multiple characters instead of just one.
  • The <string> library must be included to use string operations.
Tutorials dojo strip