home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ANSICPP.ZIP / EX10011.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-24  |  431 b   |  28 lines

  1. // ex10011.cpp
  2. // The istream get member function
  3. #include <iostream.h>
  4.  
  5. main()
  6. {
  7.     char line[25], ch = 0, *cp;
  8.  
  9.     cout << " Type a line terminated by 'x'\n>";
  10.     cp = line;
  11.     while (ch != 'x')    {
  12.         cin >> ch;
  13.         *cp++ = ch;
  14.     }
  15.     *cp = '\0';
  16.     cout << ' ' << line;
  17.  
  18.     cout << "\n Type another one\n>";
  19.     cp = line;
  20.     ch = 0;
  21.     while (ch != 'x')    {
  22.         cin.get(ch);
  23.         *cp++ = ch;
  24.     }
  25.     *cp = '\0';
  26.     cout << ' ' << line;
  27. }
  28.