Fopen () and r + w + are both read and write modes. isn't there any difference? Fopen (),
R +
W +
It's all in read/write mode. isn't there any difference? So why do we need to generate two?
You 'd better write an instance to check it out.
Reply to discussion (solution)
R "open in read-only mode. point the file pointer to the file header.
Open the "r +" read/write mode and point the file pointer to the file header.
Open the "w" write mode, point the file pointer to the file header, and cut the file size to zero. If the file does not exist, try to create it.
Open in "w +" read/write mode, point the file pointer to the file header, and cut the file size to zero. If the file does not exist, try to create it.
"A" is opened in writing mode, pointing the file pointer to the end of the file. If the file does not exist, try to create it.
Open the "a +" read/write mode and point the file pointer to the end of the file. If the file does not exist, try to create it.
As mentioned above, r + points the file pointer to the file header. At this time, when you write it in, it is the newly added content + the original content.
W + also points the file pointer to the file header, but it first clears the content before the file, and then adds the new content. The result file only contains the newly added content.
I learned