- r 只讀
- w 只寫,清空原有內(nèi)容,文件不存在會創(chuàng)建
- a 追加只寫,
- w+ 讀寫, 清空原有內(nèi)容,文件不存在會創(chuàng)建
- r+ 讀寫, 保留原有內(nèi)容
- a+ 追加讀寫,(和r+不同的地方,fseek only sets the read pointer,即只能改變讀指針,寫都是從文件尾追加)
That's because in a mode, writing to the FILE* always appends to the end. fseek only sets the read pointer in this mode.
Opening a file with append mode ('a' as the first character in the mode argument) causes all subsequent writes to the file to be forced to the then current end-of-file, regardless of intervening calls to the fseek function.