Lecture Preview: Strings

(Suggested book reading: Programming Abstractions in C++, Chapters 2-3)

C++ has a string type for storing characters of text. Here is a short example that prompts the user to type a string and then prints the string back:

string name;
cout << "Type your name: ";   // Type your name: John Doe
getline(cin, name);           // Hello, John Doe
cout << "Hello, " << name << endl;
This document and its content are copyright © Marty Stepp, 2018. All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without the authors' expressed written permission.