home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / clib / progs / utilslib / c / Efopen < prev    next >
Encoding:
Text File  |  1990-07-15  |  529 b   |  32 lines

  1. /* C.Efopen: Open file, fail if cannot open it */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "utils.h"
  6.  
  7. FILE *efopen (const char *file, const char *mode)
  8. {
  9.     FILE *p = fopen(file, mode);
  10.  
  11.     if (p == NULL)
  12.     {
  13.         fprintf(stderr, "Cannot open file %s (mode \"%s\")\n", file, mode);
  14.         exit(1);
  15.     }
  16.  
  17.     return p;
  18. }
  19.  
  20. FILE *efreopen (const char *file, const char *mode, FILE *fp)
  21. {
  22.     FILE *p = freopen(file, mode, fp);
  23.  
  24.     if (p == NULL)
  25.     {
  26.         fprintf(stderr, "Cannot open file %s (mode \"%s\")\n", file, mode);
  27.         exit(1);
  28.     }
  29.  
  30.     return p;
  31. }
  32.