開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Win32 Qt Creator MinGW32
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
無
問題(Question):
程式會讀取一 binary file 讀取裏面的資料並 print 出來
目前 for 迴圈內的狀況如下:
... FAC1
... FC91
index 累加到 2342 後讀到的資料為 FB81
index 累加到 2344 後讀到的資料為 FB41
... FB41
... FB41
但是之後讀到的資料全部都是 FB41
不瞭解,為何 fscanf 在 FB41 前可以正常讀取
但是之後卻無法正常讀取…
煩勞各位版友賜解
餵入的資料(Input):
input file 為連續的 binary file
檔案大小為 294544
預期的正確結果(Expected Output):
預期 FB41 之後的資料應該是其他資料
而不應該一直都是 FB41
錯誤結果(Wrong Output):
如上所述
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/XsbHqY4T ←完整的 code,fscanf 有改成 fread
long file_size = 294544;
long i = 0;
for( i = 0 ; i < file_size ; i += 2 ) {
fscanf( inputFilePtr, "%c%c", &raw_data[0], &raw_data[1] );
printf( "%02X%02X\n", raw_data[1], raw_data[0] );
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.74.180.10
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1419563586.A.BBF.html
→
12/26 12:37, , 1F
12/26 12:37, 1F
→
12/26 13:44, , 2F
12/26 13:44, 2F
→
12/26 14:14, , 3F
12/26 14:14, 3F
→
12/26 14:39, , 4F
12/26 14:39, 4F
→
12/26 14:39, , 5F
12/26 14:39, 5F
→
12/26 14:42, , 6F
12/26 14:42, 6F
→
12/26 14:50, , 7F
12/26 14:50, 7F
※ 編輯: frozen792 (203.74.180.10), 12/26/2014 14:51:27
→
12/26 15:03, , 8F
12/26 15:03, 8F
→
12/26 15:48, , 9F
12/26 15:48, 9F