Q. Why is it advised to close a file after we are done with the read and write operations? What will happen if we do not close it? Will some error message be flashed?


Answer :-

Closing the file releases the resources. On a large system running many process you can use up all of the resources to keep track of open files. This may prevent any process from opening another file. When the process ends or crashes the OS is supposed to clean up for you.

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )


  1. Closing the file releases the resources. On a large system running many process you can use up all of the resources to keep track of open files. This may prevent any process from opening another file. When the process ends or crashes the OS is supposed to clean up for you.

    ReplyDelete
  2. closing the file is also a good practice while coding.

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post