久久久久久久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 仍然相關嗎?)
主站蜘蛛池模板: 久久av一区二区三区 | 国产精品区二区三区日本 | 99福利| 欧美日韩一区二区视频在线观看 | 日韩一区二区三区在线视频 | 亚洲综合无码一区二区 | 欧美综合一区二区三区 | 欧美精品久久 | 国产激情网站 | 成人av免费 | 国产区第一页 | 久久精品国产免费看久久精品 | 色综合99| 午夜小电影| 青青草一区二区 | 亚洲免费三级 | 精品欧美一区二区中文字幕视频 | 91原创视频在线观看 | 精品国产一区二区久久 | 国产视频三级 | 日韩激情在线 | 99re视频在线免费观看 | 欧美一级欧美一级在线播放 | 91免费在线视频 | 精品国产伦一区二区三区观看方式 | 国产免费一区二区 | 色婷婷综合网 | 日韩成人在线视频 | 久久不卡| 国产成人午夜精品影院游乐网 | 午夜视频一区二区 | 日韩精品视频中文字幕 | 久久人人爽人人爽 | 日韩精品一区二区三区视频播放 | 天天精品在线 | 黄色电影在线免费观看 | www国产成人免费观看视频,深夜成人网 | 精品美女久久久 | 日韩精品一区二区三区在线播放 | 一区在线免费视频 | 国产精品无 |