Prayer

在一般中寻求卓越
posts - 1256, comments - 190, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

errno和strerror的使用

Posted on 2008-08-21 18:17 Prayer 阅读(2911) 评论(0)  编辑 收藏 引用 所属分类: LINUX/UNIX/AIX

erron 和 strerror的使用

看APUE上学来的


#include <stdio.h>
#include <string.h>
#include <errno.h>

int main(void)
{
 int  fd;
 extern int errno;

 if((fd = open("no/such/file",0)) < 0)
 {
  printf("errno=%d\n",errno);
  char * mesg = strerror(errno);
  printf("Mesg:%s\n",mesg);  
 }
  
 exit(0);
}



只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理