#include #include #include #include /************************************fie:open.c*author:QG*time:2015-05-10*note:exercise the function of open***********************************/void main(){ //char *name = "123.txt"; char *name = "/home/hello.c"; int a =
0; int b = 0; /********************************* *func: int open(const char *pathname, int flags); *parametre: *return:if the file opened is exist,return a positive number,otherwise return -1; *function: *********************************/ a = open(name,O_RDONLY);
if(a == -1) { printf("The file is not opened,and descriptor is %d!\n",a); } else if(a >= 0) { printf("The file is opened,and descriptor is %d!\n",a); } /********************************* *func: int open(const char *pathname, int flags, mode_t mode); *parametre:
*return:if the file opened is exist,return a positive number,otherwise return -1; *function: **********************************/ //b = open("/home/hello1.c",O_RDWR|O_CREAT,S_IRWXG); b = open("/home/hello1.c",O_RDWR|O_CREAT,0755);}

被折叠的 条评论
为什么被折叠?



