# include # include using namespace std; int main ( ) // // CHARACTER_COUNT2 allows the user to type some input, // and returns the number of characters read. // // Instead of using "cin >> c" we use " c = cin.get ( )" which // also catches new lines and other characters. // // Multiple lines of input are allowed. // // Input is terminated by the EOF (CTRL-D) character, entered on a new line. // { char c; int n = 0; cout << "Enter any textual input.\n"; cout << "Multiple lines are OK.\n"; cout << "Terminate with EOF (CTRL-D) on a new line\n"; while ( true ) { c = cin.get ( ); if ( cin.eof ( ) ) { break; } n = n + 1; } cout << "\n"; cout << "Your input consisted of " << n << " characters.\n"; return 0; }