Please send questions to
st10@humboldt.edu .
/*----------------------------------------------------------------
Contract: main: void -> int
Purpose: playing with C strings and the standard string class
Examples: demo, so not really applicable
By: Sharon M. Tuttle
last modified: 12-7-05
-----------------------------------------------------------------*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int MAX_LENGTH = 10;
string name; // a standard string class variable
char another_name[MAX_LENGTH]; // a "C string" variable
// show that cin works with standard strings
cout << "type in a name: ";
cin >> name;
// show that cin works the "C string"'s
cout << "type in another name: ";
cin >> another_name;
// ...and cout does, too
cout << "the names typed in: "
<< name << " and " << another_name << endl;
// can you assign a "C string" variable to a standard string
// variable?
name = another_name;
cout << "name is now: " << name << endl;
return EXIT_SUCCESS;
}