首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::perror

Defined in header <cstdio>

?

?

void perror( const char *s );

?

?

打印当前存储在系统变量中的错误代码的文本描述。errnostderr...

描述是通过连接以下组件来形成的:

  • 指向的以空结尾的字节字符串的内容。s%28,除非s为空指针%29
  • ": "
  • 中存储的错误代码的实现定义错误消息。errno。此消息与std::strerror(errno)...
  • '\n'...

参数

s

-

pointer to a null-terminated string with explanatory message

返回值

%280%29

二次

代码语言:javascript
复制
#include <cmath>
#include <cerrno>
#include <cstdio>
 
int main()
{
    double not_a_number = std::log(-1.0);
    if (errno == EDOM) {
        std::perror("log(-1) failed");
    }
}

二次

产出:

二次

代码语言:javascript
复制
log(-1) failed: Numerical argument out of domain

二次

另见

errno

macro which expands to POSIX-compatible thread-local error number variable(macro variable)

strerror

returns a text version of a given error code (function)

c恐怖文件

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com