home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / shrdit.zip / LOAD.C < prev    next >
Text File  |  1994-03-10  |  1KB  |  59 lines

  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. #define MAXLEN 200
  6. #define SOURCE_MAX 80
  7. #define FIELD_MAX 200
  8. #define NIL           '\0'
  9. #define TRUE          1
  10. #define FALSE         0
  11. #define END_OF_FILE   999
  12.  
  13. FILE  *inf, *outf;
  14. char  filename[20],inf_name[20], outf_name[20];
  15. char in_text[MAXLEN];
  16. int num;
  17. void main(argc, argv)
  18. int  argc;
  19. char **argv;
  20. {
  21.    int i;
  22.    char t;
  23.  
  24.    strcpy( inf_name, argv[1]);
  25.    strcpy( outf_name, argv[2]);
  26.    num=atoi(argv[3]);
  27.  
  28.    if ( (inf = fopen(inf_name,"r")) == NULL)
  29.    {
  30.      printf("Cannot open source data file %s.\n\n", inf_name);
  31.      exit(1);
  32.    }
  33.  
  34.    if ( (outf = fopen(outf_name,"w")) == NULL)
  35.    {
  36.      printf("Cannot open output file %s.\n\n", outf_name);
  37.      exit(1);
  38.    }
  39.    while (!feof(inf)){
  40.     for (i=0;i<num;i++){
  41.       t=fgetc(inf);
  42.           in_text[i]=t;
  43.     }
  44.     in_text[num]='\0';
  45.         fprintf(outf,"%s\n",in_text);
  46.    }
  47.    fclose(inf);
  48.    fclose(outf);
  49.    printf ("\nEnd of loading program.  Have a good day!!\n");
  50.    return;
  51. }
  52.  
  53. int rtrim_spaces(s)
  54. char s[];
  55. {
  56.    int i=strlen(s);
  57.    while (i>0 && s[i-1]==32) s[i-1]=s[i--];
  58. }
  59.