[問題] fstream問題
開發平台(Platform): (Ex: Win10, Linux, ...)
Win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
VS2015
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
以
ifstream in("1.txt", ifstream::in|ifstream::binary);
讀入任意txt檔
以
cout <<hex<< (int)s;
輸出
卻會在最後0x0d 0x0a(windows的換行)0x0a的部分重複
餵入的資料(Input):
任意非空白的txt檔
預期的正確結果(Expected Output):
0x0d 0x0a
錯誤結果(Wrong Output):
0x0d 0x0a 0x0a
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
https://pastebin.com/KLe9fjbu
補充說明(Supplement):
我原本是想要拿來輸出一般可執行檔的 後來發現跑出來的東西好像不太對...
感覺是在碰到EOF之前又多輸出了一次 但是一時間想不到是哪裡錯了
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.169.189.238
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1521481969.A.248.html
→
03/20 02:25,
7年前
, 1F
03/20 02:25, 1F
我有下中斷點跑過 但是還是沒有頭緒
※ 編輯: school4303 (118.169.189.238), 03/20/2018 12:33:16
→
03/20 17:39,
7年前
, 2F
03/20 17:39, 2F
→
03/20 18:56,
7年前
, 3F
03/20 18:56, 3F
→
03/20 18:59,
7年前
, 4F
03/20 18:59, 4F
→
03/20 18:59,
7年前
, 5F
03/20 18:59, 5F
推
03/20 19:33,
7年前
, 6F
03/20 19:33, 6F
推
03/21 09:42,
7年前
, 7F
03/21 09:42, 7F