[英]If two file pointers point to the same file, is closing one of them enough?
If I have two file pointers and do the following: 如果我有两个文件指针,请执行以下操作:
FILE *f1,*f2;
f1= fopen("inputfile","r+");
f2=f1;
fclose(f2);
Is the equal operation valid, if it is, will the last line close f1 as well? 相等运算是否有效(如果有效),最后一行也将关闭f1吗?
It is enough, both will be closed and both will point to a closed file. 足够了,两个都将关闭并且都将指向一个关闭的文件。
Assigning f2=f1
doesn't do anything magical (increasing a reference count or duplicating descriptors). 分配
f2=f1
并没有什么神奇的事情(增加引用计数或复制描述符)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.