Re: fclose(0)
Bartc wrote:
Of course. fclose requires a non-NULL FILE* parameter.
No, because if fopen returns a NULL (not a zero) it means the file
has not opened.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
** Posted from http://www.teranews.com **
Bartc wrote:
>
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.
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.)
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.)
has not opened.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
** Posted from http://www.teranews.com **
Comment