문제

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?

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top