home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / cpgms.zip / UNWS.C < prev   
Text File  |  1985-08-05  |  1KB  |  39 lines

  1. /* unws.c:  Program to convert a WORDSTAR file to ASCII       */
  2. #define ERROR 0
  3. #define CPMEOF 0X1A
  4.  
  5. main(argc,argv)        /* argv is the number of arguements entered
  6. int argc;               when the program is executed.  argv is
  7.                        an array of arguements.  argv[1], argv[2]  */
  8. char *argv[];         /* *argv is the pointer to the pointer to the
  9.                        string value                               */
  10. {
  11.     int fd, ofd;    
  12.     char c;
  13.  
  14.     if (argc != 3) {                    /* check for number of arguements typed */
  15.         printf("Enter, unws infile outfile \n");
  16.         exit();
  17.     }
  18.     if ((fd=fopen(argv[1],"r"))==ERROR) {  /* check for open input ERROR  */
  19.         printf("Can't open %s\n",argv[1]);
  20.         exit();
  21.     }
  22.     if ((ofd=fopen(argv[2],"w"))==ERROR) {  /* check for open output ERROR      */
  23.         printf("Can't open %s\n",argv[2]);
  24.         exit();
  25.     }
  26.     while ((c=getc(fd)) != CPMEOF) {
  27.         putchar(c);
  28.         c=(c & 0x7F);
  29.         if (c < 127) {
  30.             if (putc(c,ofd) == -1) {
  31.                 printf("Write error, is your disk full?\n");
  32.                 exit();
  33.              }
  34.          }
  35.      }
  36.      putc(CPMEOF,ofd);
  37.      fclose(ofd);
  38.      fclose(fd);
  39.  }