FILE*--fileno()--->fd;
实例如下:
#include <stdio.h>int main(){FILE *fp = NULL;int i = 0;fp = fopen("test.txt", "w+");fclose(fp);while(i++<1500){fp = fopen("test.txt", "a"); // "注意W+对int fd = fileno(fp);的影响"if (fp == NULL)return 0;fprintf(fp, "hello%d\n",i);fflush(fp);int fd = fileno(fp); //如果是W+这里文件被清空的影响write(fd, "world\n", sizeof("world\n"));fclose(fp); // close(fd);也行}}