home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011118a < prev    next >
Text File  |  1992-09-14  |  450b  |  34 lines

  1. /* concat.c:    Paste input strings together */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. #define WIDTH 80
  7. #define WRDSIZ 15
  8.  
  9. main()
  10. {
  11.     char buf[WIDTH+1], word[WRDSIZ+1];
  12.     int n = 0;
  13.    
  14.     while (gets(word))
  15.     {
  16.         if (n + strlen(word) > WIDTH)
  17.             break;
  18.         n += sprintf(buf+n,"%s",word);
  19.         puts(buf);
  20.     }
  21.     
  22.     return 0;
  23. }
  24.  
  25. Input:
  26. one
  27. two
  28. three
  29.  
  30. Output:
  31. one
  32. onetwo
  33. onetwothree
  34.