V
viza
Hi!
Is there any harm/advantage to closing the standard input stream if I am not
going to read from it again?
I have:
if(blah)
fileptr=fopen(blah);
else
fileptr=stdin;
stuff;
if(fileptr!=stdin) /*this line*/
fclose(fileptr);
Can I just miss out the marked line and close whatever fileptr is?
Also, assuming I don't need the stream again, (and I can be reasonably sure
no other process will want it in the mean time) what reason is there to
close the file at all, as exit() will eventually close all open streams
anyway?
Is there any harm/advantage to closing the standard input stream if I am not
going to read from it again?
I have:
if(blah)
fileptr=fopen(blah);
else
fileptr=stdin;
stuff;
if(fileptr!=stdin) /*this line*/
fclose(fileptr);
Can I just miss out the marked line and close whatever fileptr is?
Also, assuming I don't need the stream again, (and I can be reasonably sure
no other process will want it in the mean time) what reason is there to
close the file at all, as exit() will eventually close all open streams
anyway?