home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch2 / inout1.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  639b  |  23 lines

  1. /*                             inout1.c
  2.  *
  3.  *   Synopsis  - Takes input from the keyboard and echoes that
  4.  *               input back to the terminal.
  5.  *
  6.  *   Objective - Illustrates another use of the while loop and 
  7.  *               leads into the discussion of inout2.c.
  8.  */
  9.  
  10. /* Include Files */
  11. #include <stdio.h>
  12.  
  13. int main( void )
  14. {
  15.      int iochar;                      /* Note 1 */
  16.  
  17.      iochar = getchar();              /* Note 2 */
  18.      while ( iochar != EOF ) {        /* Note 3 */
  19.           putchar( iochar );          /* Note 4 */
  20.           iochar = getchar();         /* Note 5 */
  21.      }
  22.      return 0;
  23. }