home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap09 / scanline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-06  |  537 b   |  25 lines

  1. /* scanline.c  -- demonstrates how scanf() reads  */
  2. /*                the individual words of a line  */
  3.  
  4. #define INTRO \
  5. "Type in lines of text. They will be printed out\n\
  6. one word per line, thus demonstrating scanf().\n\
  7. (Type Ctrl-Z to Quit)\n"
  8.  
  9. main()
  10. {
  11.     char buf[512];    /* should be big enough */
  12.  
  13.     printf(INTRO);
  14.  
  15.     /*
  16.      * scanf() returns the number of items
  17.      * its control string matched.
  18.      */
  19.     while (scanf("%s", buf) == 1)
  20.         {
  21.         printf("%s\n", buf);
  22.         }
  23.     
  24. }
  25.