linux的errno

来源:互联网 发布:java坐标点的构造函数 编辑:程序博客网 时间:2024/05/18 03:02
/**g++ error_test.cpp -g -O0 -o error_test./error_test 9*/#include <errno.h>#include <stdio.h>#include <string.h>#include <stdlib.h>int main(int argc, char** argv){    if(argc <= 1){        printf("Usage: %s <errno>\nFor example:\n    %s 9\n", argv[0], argv[0]);        exit(1);    }    int no = atoi(argv[1]);    printf("error=%d(%#x)(%s)\n", no, no, strerror(no));    return 0;}

执行结果如下:

[winlin@localhost zmq]$ g++ error_test.cpp -g -O0 -o error_test[winlin@localhost zmq]$ ./error_testUsage: ./error_test <errno>For example:    ./error_test 9[winlin@localhost zmq]$ ./error_test 9error=9(0x9)(Bad file descriptor)


原创粉丝点击