// testgetline.cpp // Program to test clear and ignore member functions // of cin. // Ray S. Babcock // 2/6/03 // #include using namespace std; int main (void) { int my_i(99); char name[25]="xxx"; cout << "Enter a value for my_i: "; cin >> my_i; //cin.clear(); // clear input cin.ignore(); // ignore next character (new line) cout << "Enter a name: "; cin.getline(name, 25); cout << "my_i = " << my_i << ", name = " << name << endl; // check to see what is left in name cout << "name[1] = " << name[1] << ", and name[2] = " << name[2]; cout << endl; }