1234567891011121314151617181920212223 |
- // textin2.cpp -- using cin.get(char)
- #include <iostream>
- int main()
- {
- using namespace std;
- char ch;
- int count = 0;
- cout << "Enter characters; enter # to quit:\n";
- cin.get(ch); // use the cin.get(ch) function
- while (ch != '#')
- {
- cout << ch;
- ++count;
- cin.get(ch); // use it again
- }
- cout << endl << count << " characters read\n";
- // get rid of rest of line
- // while (cin.get() != '\n')
- // ;
- //cin.get();
- return 0;
- }
|