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

以二進制和文本模式編寫的文件的區別

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

問題描述

寫入以文本模式打開但在二進制模式下沒有發生的文件時會發生什么轉換?特別是在 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);

推薦答案

我相信大多數平臺在處理流時都會忽略t"選項或text-mode"選項.然而,在 Windows 上,情況并非如此.如果您查看以下 fopen() 函數的說明: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:

  • 換行符 (' ') 將在輸出時轉換為 ' " 序列
  • 回車/換行序列將在輸入時轉換為換行.
  • 如果文件以追加模式打開,將檢查文件末尾是否有 ctrl-z 字符(字符 26),并在可能的情況下刪除該字符.它還將將該字符的存在解釋為文件結尾.這是從 CPM 時代(關于父母的罪孽一直延續到他們的孩子直到第三代或第四代)的不幸遺留.與先前陳述的意見相反,不會附加 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.

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

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

相關文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉換為 HSV 并將 HSV 轉換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉換為字符串?)
When to use inline function and when not to use it?(什么時候使用內聯函數,什么時候不使用?)
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 仍然相關嗎?)
主站蜘蛛池模板: 国产日韩视频 | 亚洲人成人一区二区在线观看 | 亚洲va欧美va人人爽午夜 | av黄色网| 日本在线小视频 | 久久精品一区二区 | 天堂av中文在线 | 亚洲国产成人精品女人久久久 | h在线免费观看 | 国产精品免费视频一区 | 99久久精品一区二区毛片吞精 | 在线黄色影院 | 青青草华人在线视频 | 欧美一级黄视频 | 99re在线| 色性av | 在线视频一区二区 | 精品亚洲一区二区三区 | 免费观看色 | 国产精品美女www爽爽爽视频 | 亚洲人免费视频 | 中文字幕免费视频 | 日韩福利| 亚洲精品一区二区三区在线 | 欧美二级 | 亚洲精品视频在线观看视频 | 中文字幕av一区二区三区 | 亚洲视频免费观看 | 久久久精品视频一区二区三区 | 91麻豆蜜桃一区二区三区 | 亚洲男女激情 | 人人草天天草 | 在线免费观看黄色网址 | 国产男女视频网站 | 五月婷亚洲 | 中文字幕99 | 黄色网址在线免费观看 | 日韩精品一区二区三区中文在线 | 国产精品久久久久久52avav | 97伦理最新伦理 | 久久不卡日韩美女 |