[問題] 讀檔程式會當掉

看板C_and_CPP作者 (wi)時間14年前 (2011/08/19 18:35), 編輯推噓3(3012)
留言15則, 4人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) cb10.05 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 程式編譯會過 但是在讀檔的時候會當掉 餵入的資料(Input): 讀入八個txt檔 其中有兩個容量為2.2mb 預期的正確結果(Expected Output): 讀檔正確 錯誤結果(Wrong Output): 程式當掉 程式碼(Code):(請善用置底文網頁, 記得排版) http://nopaste.info/ed98180647.html 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.125.20.92

08/19 18:39, , 1F
各別讀檔OK嗎?
08/19 18:39, 1F

08/19 18:41, , 2F
讀到iTrans1.txt跟iTrans1.txt兩個2.2mb的檔案就會當
08/19 18:41, 2F

08/19 18:42, , 3F
適當地加printf(" ") 應該可以知道程式跑到哪一行之後
08/19 18:42, 3F

08/19 18:44, , 4F
程式只要一開錯出錯,我都註解掉只剩下宣告的
08/19 18:44, 4F

08/19 18:45, , 5F
一開會出現說program received signal SIGSEGV, Segm
08/19 18:45, 5F

08/19 18:45, , 6F
Segmentation fault會是我宣告的太大嗎?
08/19 18:45, 6F

08/19 18:46, , 7F
你的程式我沒辦法人工compiler (風格不同)
08/19 18:46, 7F

08/19 18:46, , 8F
file_iTrans1>>iTrans1[i][j];
08/19 18:46, 8F

08/19 18:47, , 9F
你確定這樣寫只會丟一個資料過去, 就好.
08/19 18:47, 9F

08/19 18:54, , 10F
http://www.funp.net/index.php 原始資料壓過放上去.
08/19 18:54, 10F

08/19 19:42, , 11F
我把程式都註解掉,只剩下宣告而已也是不能過...
08/19 19:42, 11F

08/19 19:42, , 12F
480*640*8byte stack不夠放了
08/19 19:42, 12F

08/19 19:42, , 13F
改用new去要空間 或者 宣告成static double [][]試試
08/19 19:42, 13F

08/19 19:46, , 14F
了解!我在嘗試看看
08/19 19:46, 14F

08/19 19:51, , 15F
我改用vector就成功了
08/19 19:51, 15F
文章代碼(AID): #1EJZoFLm (C_and_CPP)