// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI/CMPE 1170, Spring 2009 // Lab 2: cin, getline(), cin.get(), cin.ignore() // Date: January 12, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // // Practice cin, getline(), cin.get, cin.ignore // // Compile and run your program. When everything is fine, // print your .cpp file and turn it to me or the TA. // ***************************************************************** #include < iostream > #include < string > using namespace std; int main( ) { //variable declarations string firstName, lastName; //vars to store names and answer string name; //var to store a full name with space string line; //var to store a string of characters with spaces char ch; //var to store one character int x, y; //vars to store integers string str; //var to a string //cin cannot get blanks (or white spaces) //That is, a blank in the input stop cin cout << "What is your first name? "; cin >> firstName; cout << "What is your last name? "; cin >> lastName; cout< "; cin >> firstName >> lastName; cout << "The name is " << firstName << " " < "; cin >> name; cout << "The name is " << name <> name; cout<< "\nSee what another cin gets is ==> " <"; getline(cin, line); cout<<"\nSee what getline gets ==> " <"; cin.get(ch); cin.ignore(20, 't'); getline(cin, line); cout<<"\nSee what the result ==> " <