String Types
The string
type is used to store a sequence of characters (text). This is not a built-in type, but it behaves like one in its most basic usage. String values must be surrounded by double quotes:
Example:
string greeting = "Hello";
cout << greeting;
To use strings, you must include an additional header file in the source code, the
<string>
library:
Example:
#include <iostream>
#include <string>
using namespace std;
int main() {
string greeting = "Hello Raj";
cout << greeting;
return 0;
}
// Output---> Hello Raj
You will learn more about strings, in our C++ Strings Chapter.