日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CFile和CStdioFile的区别以及‘\r’、‘\r\n’

發布時間:2025/3/20 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CFile和CStdioFile的区别以及‘\r’、‘\r\n’ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉自:http://blog.csdn.net/davidhsing/archive/2007/08/26/1759494.aspx

MSDN:

Difference between text mode file and binary mode file
File I/O operations take place in one of two translation modes, text or binary, depending on the mode in which the file is opened. Data files are usually processed in text mode. To control the file translation mode, you can:
a. Retain the current default setting and specify the alternative mode only when you open selected files.
b. Change the default translation mode directly by setting the global variable _fmode in your program. The initial default setting of _fmode is _O_TEXT, for text mode.

Text mode provides special processing for carriage return–linefeed pairs. When you write a newline character (0x0A) to a text-mode CStdioFile object, the byte pair (0x0D, 0x0A) is sent to the file. When you read, the byte pair (0x0A, 0x0D) is translated to a single 0x0A byte.

Note:

CStdioFile::ReadString
The CString version of this function removes the '/n' if present; the LPTSTR version does not.

說明:

這幾段MSDN中的文字(來自主題:CStdioFile::ReadString)說明的問題是:

?
CFile類操作文件默認的是Binary模式CStdioFile類操作文件默認的是Text模式


在Binary模式下我們必須輸入'\r\n',才能起到回車換行的效果,'\r'只是回車(回到當前行的第一列),'\n'只是換行(到達下一行的當前列)。


而在Text模式下'\r'的工作是自動完成的,當我們寫一個'\n'的時候,系統會自動幫我們在其前面加上一個'\r',然后保存到文件里。

另外,CFile::typeText只能在CFile的子類中使用,CFile自身的Read函數不能使用CFile::typeText和CFile::typeBinary

轉載于:https://www.cnblogs.com/qinfengxiaoyue/archive/2013/01/31/2888293.html

總結

以上是生活随笔為你收集整理的CFile和CStdioFile的区别以及‘\r’、‘\r\n’的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。