home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list14_3.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  286b  |  19 lines

  1.  /* Using getchar() to input strings. */
  2.  
  3.  #include <stdio.h>
  4.  
  5.  #define MAX 80
  6.  
  7.  main()
  8.  {
  9.      char ch, buffer[MAX+1];
  10.      int x = 0;
  11.  
  12.      while ((ch = getchar()) != '\n' && x < MAX)
  13.          buffer[x++] = ch;
  14.  
  15.      buffer[x] = '\0';
  16.  
  17.      printf("%s", buffer);
  18.  }
  19.