__fseterr() — Set stream in error
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Language Environment | both |
Format
#include <stdio.h>
#include <stdio_ext.h>
void __fseterr(FILE *stream);
General description
The __fseterr() function sets the specified stream in error.
Returned value
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.
- Error Code
- Description
- EBADF
- The stream specified by stream is not valid.
Example
CELEBF88
/* 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;
}
Output
The error indicator is not set for the open stream
The error indicator is set for the open stream