文件操作筆記

1.在read和write間切換時一定要調用fseek,即使是位置不變也要調用一下fseek(file,0, SEEK_CUR);
2.在a+模式下,read完後要seek,不然寫不出來;seek完後write一定寫在最後,無論你seek在什麼位置。a也一樣寫在最後,但不seek也能寫。
3.fopen是c函數具有緩衝區,_open好象沒有?是內核調用
4.t模式在windows會在回車符前自動加0x0d,統一加上b好了
5.估計fopen是_open的封裝,有特殊要求可以自己寫一個buff封裝一個

6.When the “r+”, “w+”, or “a+” access type is specified, both reading and writing are enabled (the file is said to be open for “update”). However, when you switch from reading to writing, the input operation must encounter an EOF marker. If there is no EOF, you must use an intervening call to a file positioning function. The file positioning functions are fsetpos, fseek, and rewind. When you switch from writing to reading, you must use an intervening call to either fflush or to a file positioning function.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章