/**
* This program is a simple example of using
* the string class that comes
* with the STDC++ Library.
*
* @creator gdt
* @created 02001.12.20
* @version 02016.10.01
*
* @edu Used after the concept of a class has
* been introduced. Typically, C strings have
* been covered along with the string related
* functions from the STDC Library .
*/
#include
#include
#include
using namespace std;
int main(int, char**) {
const int MAX_LENGTH = 64;
string name; //string is a class
cout << "Enter your name: " << flush;
getline(cin, name);
cout << "Your name is " << name << endl;
char other[MAX_LENGTH];
cout << "Enter another name: " << flush;
cin >> other;
cout << "The other name is " << other << endl;
return EXIT_SUCCESS;
}
/*
getline(cin, name) reads from the cin object
characters into name until a newline character
is encountered; the newline is not copied into
the buffer, however, it is removed from the
input stream
*/
/*** program generated output (inputs are in brackets <>)
Enter your name:
Your name is John Doe
Enter another name:
The other name is Mary
***/