std:: perror
From cppreference.net
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
C-style I/O
| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダー
<cstdio>
で定義
|
||
|
void
perror
(
const
char
*
s
)
;
|
||
現在システム変数 errno に格納されているエラーコードのテキストによる説明を stderr に出力します。
説明は以下のコンポーネントを連結して形成されます:
- s が指すnull終端バイト文字列の内容( s がnullポインタである場合、または s が指す文字がnull文字である場合を除く)に続けて ": " を出力。
-
errnoに格納されたエラーコードを説明する実装定義のエラーメッセージ文字列に続けて ' \n ' を出力。エラーメッセージ文字列は std:: strerror ( errno ) の結果と同一。
目次 |
パラメータ
| s | - | 説明メッセージを含むnull終端文字列へのポインタ |
戻り値
(なし)
例
このコードを実行
#include <cerrno> #include <cmath> #include <cstdio> int main() { double not_a_number = std::log(-1.0); if (errno == EDOM) std::perror("log(-1) failed"); std::printf("%f\n", not_a_number); }
出力例:
log(-1) failed: Numerical argument out of domain nan
関連項目
|
POSIX互換のスレッドローカルエラー番号変数に展開されるマクロ
(マクロ変数) |
|
|
指定されたエラーコードのテキスト版を返す
(関数) |
|
|
Cドキュメント
for
perror
|
|