トップページ > キーワード検索 > perror()
C言語規格
C言語(その他)
プログラム
その他
perror()
機能 errnoのエラー番号に対応するエラーメッセージを生成して標準エラーストリームへ出力することを表す。
定義 #include <stdio.h>

void perror ( const char * s );
引数
sエラーメッセージに付加する文字列
実装例
#include <stdio.h>

int main(void)
{
    FILE *fp;
    
    fp = fopen("test.txt", "r");
    
    if (NULL != fp) {
        
        fputc('a', fp);  /* エラー発生 */
        
        perror("TEST");
        
        fclose(fp);
    }
    
    return 0;
}
実行結果
TEST: Bad file descriptor





inserted by FC2 system