[問題] fgets讀檔同時strtok分隔後儲存

看板C_and_CPP (C/C++)作者 (椪柑)時間13年前 (2012/12/22 16:33), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) GCC 問題(Question): 在迴圈裡fgets,再strtok分割後儲存、印出結果正確 但是出迴圈再印資料會損失 餵入的資料(Input): input.txt 1,Tammy J. Connors,TammyJConnors@teleworm.us,580-228-1482 2,Lewis S. Archer,LewisSArcher@teleworm.us,904-305-6505 預期的正確結果(Expected Output): 1,Tammy J. Connors,TammyJConnors@teleworm.us,580-228-1482 2,Lewis S. Archer,LewisSArcher@teleworm.us,904-305-6505 錯誤結果(Wrong Output): 1,Lewis S. Archer,ewisSArcher@teleworm.us,4-305-6505 2,Lewis S. Archer,LewisSarcher@teleworm.us,904-3056505 0,<null>,<null>,<null> 程式碼(Code):(請善用置底文網頁, 記得排版) http://pastie.org/5564492 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.221.54

12/22 16:49, , 1F
你只存了一個指標 並沒有存進那個字串
12/22 16:49, 1F
原來如此 了解 我再試試看別的方法.. ※ 編輯: kids1243 來自: 140.114.221.54 (12/22 16:54)
文章代碼(AID): #1GrN1dMd (C_and_CPP)
文章代碼(AID): #1GrN1dMd (C_and_CPP)