home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 280_01 / concat0.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-13  |  1.6 KB  |  70 lines

  1. /* [concat0.c of JUGPDS Vol.46] */
  2. /*
  3. *****************************************************************
  4. *                                *
  5. *    Written by  Hakuo Katayose (JUG-CP/M No.179)        *
  6. *            49-114 Kawauchi-Sanjuunin-machi        *
  7. *            Sendai, Miyagi 980                          *
  8. *            Phone: 0222-61-3219                *
  9. *                                *
  10. *       Modifird by Toshiya Oota   (JUG-CPM No.10)              *
  11. *                   Sakae ko-po 205                 *
  12. *            5-19-6 Hosoda                *
  13. *            Katusikaku Tokyo 124            *
  14. *                                *
  15. *        for MS-DOS Lattice C V3.1J & 80186/V20/V30    *
  16. *                                *
  17. *    Compiler Option: -ccu -k0(1) -ms -n -v -w        *
  18. *                                *
  19. *    Edited & tested by Y. Monma (JUG-CP/M Disk Editor)    *
  20. *            &  T. Ota   (JUG-CP/M Sub Disk Editor)    *
  21. *                                *
  22. *****************************************************************
  23. */
  24.  
  25. /* Library functions for Software Tools */
  26.  
  27. #include "stdio.h"
  28. #include "dos.h"
  29. #include "ctype.h"
  30. #include "tools.h"
  31. #include "toolfunc.h"
  32.  
  33. /* concat - concatenate named files onto standard output */
  34.  
  35. void    main(argc, argv)
  36. int    argc;
  37. char     **argv;
  38.  
  39. {
  40. FILE *fp;
  41. void    filecopy();
  42.  
  43.     if (argc < 2) {
  44.         error("CON911 Usage: concat0 file1 file2 ... >outfile");
  45.         exit();
  46.         }
  47.     if (argc == 1)
  48.         filecopy(STDIN);
  49.     else
  50.         while (--argc > 0)
  51.             if ((fp = fopen(*++argv,"r")) == NO ) {
  52.                 printf("\nCON912 can't open %s\n", *argv);
  53.                 exit(1);
  54.                 }
  55.             else {
  56.                 filecopy(fp);
  57.                 fclose(fp);
  58.                 }
  59. }
  60.  
  61.  
  62. void filecopy(inbuf)
  63. FILE *inbuf;
  64. {
  65. int c;
  66.  
  67.     while ((c = getc(inbuf)) != EOF)
  68.         putchar(c);
  69. }
  70.