Strings:
- A data type to accept a string of characters.
- Requires the string library: #include ‹string›;
- Declaration: string name;
- Assignment: name = "Fred";
//enclosed in double quotes.
- Reading: cin >> name;
//only reads to a space or return.
- getline (cin, name);
reads everything until a return.
- cin.ignore(80,'\n');
skips to the next line. E.g.:
cin >> age;
cin.ignore(80,'\n'); needed or name is read as the linefeed
and empty.
cin >> name;
- Operations on strings?