__fseterr() — ストリームのエラーの設定

標準

標準/拡張機能 C/C++ 依存項目
Language Environment 両方  

形式

#include <stdio.h>
#include <stdio_ext.h>

void __fseterr(FILE *stream);

機能説明

__fseterr() 関数は、指定されたストリームをエラーに設定します。

戻り値

__fseterr() 関数は、値を戻しません。

エラー状態を検査するアプリケーションは、errno を 0 に設定し、__fseterr() を呼び出してから、errno を検査する必要があります。errno がゼロ以外である場合、エラーが発生したと想定されます。

エラー・コード
説明
EBADF
stream によって指定されたストリームは無効です。

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;
}
出力:
The error indicator is not set for the open stream
The error indicator is set for the open stream  

関連情報