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 가 가리키는 널 종료 바이트 문자열의 내용( s 가 널 포인터이거나 s 가 가리키는 문자가 널 문자인 경우는 제외) 뒤에 ": " 가 붙습니다.
-
errno에 저장된 오류 코드를 설명하는 구현 정의 오류 메시지 문자열 뒤에 ' \n ' 가 붙습니다. 오류 메시지 문자열은 std:: strerror ( errno ) 의 결과와 동일합니다.
목차 |
매개변수
| s | - | 널 종료 문자열에 대한 포인터 (설명 메시지 포함) |
반환값
(없음)
예제
이 코드 실행
#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 documentation
for
perror
|
|