错误号,字符串错误和Linux系统调用 [英] errno, strerror and Linux system calls

查看:96
本文介绍了错误号,字符串错误和Linux系统调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用字符串错误得到错误值的文本再presentation使用CRT函数后,例如的fopen 。如果我使用打开 Linux系统调用,而不是CRT的功能,它也失败时设置错误值。这是正确适用于strerror这个错误值?如果没有,是否有一些Linux系统调用,它不一样的字符串错误?

I can use strerror to get text representation of errno value after using CRT functions, like fopen. If I use open Linux system call instead of CRT function, it also sets errno value when fails. Is this correct to apply strerror to this errno value? If not, is there some Linux system call, which does the same as strerror?

推荐答案

在有 PERROR

if (-1 == open(....))
{
    perror("Could not open input file");
    exit(255)
}

这篇关于错误号,字符串错误和Linux系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆