home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch12 / io1.cpp < prev    next >
C/C++ Source or Header  |  2005-06-16  |  993b  |  37 lines

  1. //             io1.cpp
  2. //
  3. // Synopsis  - Prompts for and accepts input of a 
  4. //             character, and echoes it to the terminal
  5. //             screen. Prompts for and accepts input 
  6. //             of a line of text and echoes it to 
  7. //             the screen.
  8. //
  9. // Objective - To demonstrate the use of cout and cin 
  10. //             member functions
  11. //
  12.  
  13. // Include Files
  14. #include <iostream.h>
  15. #include <string.h>
  16.  
  17. int main()
  18. {
  19.     char ch;
  20.     char array[80];
  21.     cout << "Please enter a character: ";
  22.     cin.get( ch );                                   // Note 1
  23.     cout.put( '|' );                                 // Note 2
  24.     cout.put( ch );
  25.     cout.put( '|' );
  26.     cout.put( '\n' );
  27.  
  28.     cin.ignore();                                   // Note 3
  29.  
  30.     cout << "Enter a line of text: ";
  31.     cin.getline( array, 80 );                       // Note 4
  32.     cout.write( array, strlen(array) );             // Note 5
  33.     cout << endl;
  34.  
  35.     return 0;
  36. }
  37.