/* * cinfunc.cpp * demonstration of some istream functions * CIS 250 * David Klick * 2014-01-04 * */ #include #include using std::cin; using std::cout; using std::endl; using std::string; int main(int argc, char* argv[]) { char c; int i; string s; for (i=0; i<10; i++) { cin >> c; cout << c; } cout << endl; cin.ignore(200, '\n'); for (i=0; i<10; i++) { cin.get(c); cout << c; } cout << endl; cin.ignore(200, '\n'); getline(cin, s); cout << s << endl; cin.get(c); cout << c << endl; cin.get(c); cout << c << endl; c = cin.peek(); cout << c << endl; cin.get(c); cout << c << endl; cin.get(c); cout << c << endl; cin.get(c); cout << c << endl; cin.putback(c); cout << c << endl; cin.get(c); cout << c << endl; return 0; } /* Sample input/output: we are writing a program wearewriti we are writing a program we are wri we are programming we are programming we are writing a program w e a r r r */