home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / internet / wsplug31.zip / ADDONETO.C < prev    next >
Text File  |  1996-02-06  |  599b  |  37 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <io.h>
  4. #include <string.h>
  5.  
  6. main(argc,argv)
  7. int argc;
  8. char **argv;
  9. { FILE *f  ;
  10.   unsigned long value ;
  11.   int nb              ;
  12.  
  13.   if (argc < 2)
  14.   { printf("Missing arguments ...\n") ;
  15.     printf("addoneto filename ...\n") ;
  16.     return(0);
  17.   }
  18.  
  19.  
  20.   f = fopen(argv[1],"a+b") ;
  21.   if (f != NULL)
  22.   {  nb = fscanf(f,"%lu",&value) ;
  23.      if (nb <= 0) value = 0 ;
  24.      value += 1 ;
  25.      fclose(f)  ;
  26.   }
  27.  
  28.   f = fopen(argv[1],"w+b")  ;
  29.   if (f != NULL)
  30.   {  fprintf(f,"%lu",value) ;
  31.      fclose(f) ;
  32.   }
  33.   return(0) ;
  34.  
  35. }
  36.  
  37.