久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

以二進制和文本模式編寫的文件的區(qū)別

Difference between files written in binary and text mode(以二進制和文本模式編寫的文件的區(qū)別)
本文介紹了以二進制和文本模式編寫的文件的區(qū)別的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

寫入以文本模式打開但在二進制模式下沒有發(fā)生的文件時會發(fā)生什么轉(zhuǎn)換?特別是在 MS Visual C 中.

What translation occurs when writing to a file that was opened in text mode that does not occur in binary mode? Specifically in MS Visual C.

unsigned char buffer[256];
for (int i = 0; i < 256; i++) buffer[i]=i;
int size  = 1;
int count = 256;

二進制模式:

FILE *fp_binary = fopen(filename, "wb");
fwrite(buffer, size, count, fp_binary);

與文本模式:

FILE *fp_text = fopen(filename, "wt");
fwrite(buffer, size, count, fp_text);

推薦答案

我相信大多數(shù)平臺在處理流時都會忽略t"選項或text-mode"選項.然而,在 Windows 上,情況并非如此.如果您查看以下 fopen() 函數(shù)的說明:MSDN,你會看到指定"t"選項會有如下效果:

I believe that most platforms will ignore the "t" option or the "text-mode" option when dealing with streams. On windows, however, this is not the case. If you take a look at the description of the fopen() function at: MSDN, you will see that specifying the "t" option will have the following effect:

  • 換行符 (' ') 將在輸出時轉(zhuǎn)換為 ' " 序列
  • 回車/換行序列將在輸入時轉(zhuǎn)換為換行.
  • 如果文件以追加模式打開,將檢查文件末尾是否有 ctrl-z 字符(字符 26),并在可能的情況下刪除該字符.它還將將該字符的存在解釋為文件結(jié)尾.這是從 CPM 時代(關(guān)于父母的罪孽一直延續(xù)到他們的孩子直到第三代或第四代)的不幸遺留.與先前陳述的意見相反,不會附加 ctrl-z 字符.
  • line feeds (' ') will be translated to ' " sequences on output
  • carriage return/line feed sequences will be translated to line feeds on input.
  • If the file is opened in append mode, the end of the file will be examined for a ctrl-z character (character 26) and that character removed, if possible. It will also interpret the presence of that character as being the end of file. This is an unfortunate holdover from the days of CPM (something about the sins of the parents being visited upon their children up to the 3rd or 4th generation). Contrary to previously stated opinion, the ctrl-z character will not be appended.

這篇關(guān)于以二進制和文本模式編寫的文件的區(qū)別的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉(zhuǎn)換為 HSV 并將 HSV 轉(zhuǎn)換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉(zhuǎn)換為字符串?)
When to use inline function and when not to use it?(什么時候使用內(nèi)聯(lián)函數(shù),什么時候不使用?)
Examples of good gotos in C or C++(C 或 C++ 中好的 goto 示例)
Significance of ios_base::sync_with_stdio(false); cin.tie(NULL);(ios_base::sync_with_stdio(false) 的意義;cin.tie(NULL);)
Is TCHAR still relevant?(TCHAR 仍然相關(guān)嗎?)
主站蜘蛛池模板: 亚洲欧美国产高清va在线播放 | 日本一区二区不卡视频 | 成人精品免费视频 | a免费视频 | 国产精品欧美精品 | 国产一区在线视频 | 国产精品福利视频 | 欧美视频在线观看免费 | 欧美成人精品欧美一级私黄 | 久久网av| 久久成人综合 | 欧美mv日韩mv国产 | 亚洲欧美一区二区三区在线 | 亚洲经典一区二区 | aaaaaa毛片| 亚洲免费毛片 | 日本一区二区三区在线视频 | 精品国产区一区二 | 日本一级大毛片a一 | 国产精品国产三级国产 | 看毛片网站| 一区二区三区日韩 | 午夜专区| 日韩精品一级毛片在线播放 | av影片在线观看 | 91精品久久久久久久久 | 国产日韩欧美日韩大片 | 天天爽天天 | 欧美一级特黄aa大片 | 性久久 | 国产黄色一区 | 午夜黄色影院 | 亚洲一区二区三区免费视频 | 一级免费看 | 欧美 日韩 国产 成人 在线 | 国产福利91精品一区二区三区 | 午夜在线看片 | 国产在线不卡视频 | 国产精品一区视频 | 国产日本在线 | 欧美成人黄色 |