標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
Language Environment | 両方 |
#include <stdio.h>
#include <stdio_ext.h>
void __fseterr(FILE *stream);
__fseterr() 関数は、指定されたストリームをエラーに設定します。
__fseterr() 関数は、値を戻しません。
エラー状態を検査するアプリケーションは、errno を 0 に設定し、__fseterr() を呼び出してから、errno を検査する必要があります。errno がゼロ以外である場合、エラーが発生したと想定されます。
/* 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