0
File closing
What is the effect on code when we don't close the file?
3 ответов
+ 7
It affects the file not the code.
https://www.sololearn.com/discuss/1958980/?ref=app
https://www.sololearn.com/discuss/1652963/?ref=app
+ 5
A lot of information about this issue. So from my experience, keeping a file open, is a high risk when the program crashes before a file will be closed. I have done a small test program that is doing:
- creating a file, writing to this file, closing this file
- opening the file, reading the created file and display the file content, closing this file
- opening the created file again, write information to the file, and create a crash
-> The result is, that the COMPLETE content of the file is gone.
You can try the code in the attached file, but it does not work in playground, as file we create there are only temporary during runtime of the program.
https://code.sololearn.com/c1RcN9OkVDIC/?ref=app