B
Bartc
This short program:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int status;
status=fclose(0);
printf("fclose(0) status: %d\n",status);
}
crashes on the first two implementations I tried. Then I tried DMC and that
gave the expected EOF status.
Given the emphasis on error-checking in this group, it seems astonishing
that a library function (executed at most once per file) cannot do this
elementary check on it's parameter.
(It's possible a zero FILE* handle is returned by fopen() but the file has
to be closed for other reasons before it can checked by the application.)
Was I unlucky or is it normal for C library functions to be so fragile?
-- Bart
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int status;
status=fclose(0);
printf("fclose(0) status: %d\n",status);
}
crashes on the first two implementations I tried. Then I tried DMC and that
gave the expected EOF status.
Given the emphasis on error-checking in this group, it seems astonishing
that a library function (executed at most once per file) cannot do this
elementary check on it's parameter.
(It's possible a zero FILE* handle is returned by fopen() but the file has
to be closed for other reasons before it can checked by the application.)
Was I unlucky or is it normal for C library functions to be so fragile?
-- Bart