Reputation: 45
Let's say I have somewhere in my program a function that opens a file with fopen
and then my program does something else (say, try to calculate something) and then it crashes, because of some Null pointer, or stack overflow, or segmentation fault etc. Is there any chance that this would destroy/mess up the file I opened?
What if I opened it for writing. Would it then be even more dangerous?
Upvotes: 0
Views: 580
Reputation: 10048
If you open a file for reading then no, you cannot corrupt a file.
If you open a file for writing then yes, it is always possible to leave the file in some corrupt state.
Upvotes: 2