previous | start | next

## Strings

- To use the `string` type, include the header file for `string`s: `#include<string>`.
- C++ `string`s are enclosed in quotes, which are not part of the `string`.
- The string type behaves like number types with respect to declaration, assignment, output and input:

  >     string name = "John"; // declaration and initialization
  >     name = "Carl"; // assignment
  >     cout << "Please enter your name:"; // output
  >     cin >> name; // input (stops at first space)

- Use the statement

  > `getline(cin, name);`

  to read all keystrokes until the `Enter` key; e.g. should the user type

  > `Harry Hacker`

previous | start | next