home *** CD-ROM | disk | FTP | other *** search
- /* C.Efopen: Open file, fail if cannot open it */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "utils.h"
-
- FILE *efopen (const char *file, const char *mode)
- {
- FILE *p = fopen(file, mode);
-
- if (p == NULL)
- {
- fprintf(stderr, "Cannot open file %s (mode \"%s\")\n", file, mode);
- exit(1);
- }
-
- return p;
- }
-
- FILE *efreopen (const char *file, const char *mode, FILE *fp)
- {
- FILE *p = freopen(file, mode, fp);
-
- if (p == NULL)
- {
- fprintf(stderr, "Cannot open file %s (mode \"%s\")\n", file, mode);
- exit(1);
- }
-
- return p;
- }
-