网站开发石家庄,网络规划设计师考试科目,软件开发周期,网站 规划1、fdopen(int fd, const char *type)的介绍
比如一写特殊文件不能用io打开,我们先要用open函数得到文件描述符,也就是这个fdopen函数的第一个参数,第二个参数是常量,不同类型不同意义,如下图
2、代码演示 #includestdio.h
#includefcntl.hint main…1、fdopen(int fd, const char *type)的介绍
比如一写特殊文件不能用io打开,我们先要用open函数得到文件描述符,也就是这个fdopen函数的第一个参数,第二个参数是常量,不同类型不同意义,如下图 2、代码演示 #includestdio.h
#includefcntl.hint main(void)
{FILE *fp;int fd;if ((fp = fopen("hello.txt", "w+")) == NULL) {printf("fopen file error\n");return 0;}fprintf(fp, "hello word\n");fclose(fp);if ((fd = open("hello.txt", O_RDWR)) == -1) {printf("open file fail\n");return 0;}if ((fp = fdopen(fd, "a+")) == NULL) {printf("