Question:
What happens if I exit program without closing files?
Are there some bad things happening (e.g. some OS level file descriptor array is not freed up..?)
And to the answer the same in both cases
- programmed exiting
- unexpected crash
Code examples:
With programmed exiting I mean something like this:
int main(){
fopen("foo.txt","r");
exit(1);
}
With unexpected crash I mean something like this:
int main(){
int * ptr=NULL;
fopen("foo.txt","r");
ptr[0]=0; // causes segmentation fault to occur
}
P.S.
If the answer is programming language dependent then I would like to know about C and C++.
If the answer is OS dependent then I am interested in Linux and Windows behaviour.