Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Language Environment | both |
#include <stdio.h>
#include <stdio_ext.h>
void __fseterr(FILE *stream);
The __fseterr() function sets the specified stream in error.
The __fseterr() function returns no values.
An application wishing to check for error situations should set errno to 0, then call __fseterr(), and then check errno. If errno is nonzero, assume that an error has occurred.
/* CELEBF88
This example sets a stream in error.
*/
#include <stdio.h>
#include <stdio_ext.h>
void main() {
FILE *f;
char filename[FILENAME_MAX] = "myfile.dat";
f = fopen(filename,"wb");
if (f == NULL) {
perror("fopen failed\n");
return;
}
if (ferror(f)) printf("The error indicator is set for the open stream\n");
else printf("The error indicator is not set for the open stream\n");
__fseterr(f);
if (ferror(f)) printf("The error indicator is set for the open stream\n");
else printf("The error indicator is not set for the open stream\n");
return;
}
The error indicator is not set for the open stream
The error indicator is set for the open stream