What is the difference between a file opened with "r+" and one opened with "w+"?

File opened with r+

  • Open file for read/write
  • If file exists, read from start
  • If file doesn't exist, failure

File opened with w+

  • Create file for read/write
  • If file exists, destroy content
  • If file doesn't exist, create new file

Add comment


Security code
Refresh