[問題] 輸入檔案的數字到陣列中

看板C_and_CPP (C/C++)作者 (tur)時間10年前 (2015/05/31 01:09), 10年前編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
各位大大好 小弟我目前有一個檔案 裡面有12行每行有很多數字 要來記錄地圖的檔案 我想要把檔案裡的每個數字一個一個取出來 把它放到一個二維陣列裡面 但是我在int 跟 char 的轉換遇到了問題 可能我對這些還不夠理解 因此想要請問一下各位大大 下面是我的程式碼: #include <stdio.h> #include<stdlib.h> int main() { int a[12][12]; int i,j,k; char m[10]; FILE *fin; fin=fopen( "a.txt","r" ) ; if( ( fin== NULL ) ) { printf( "無法開啟a.txt!!\n" ); } for(i=0;i<=11;i++) { for(j=0;j<=11;j++) { while( !feof( fin ) ) { char p[]=fgetc(fin); 錯誤出現這這裡 到我看不懂他 m[0]=p[0]; DEBUG的訊息 k=atoi(m); a[i][j]=k; } } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.228.123.70 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1433005742.A.093.html ※ 編輯: yoyo50420 (36.228.123.70), 05/31/2015 01:10:03

05/31 01:28, , 1F
這不是C#
05/31 01:28, 1F

05/31 03:20, , 2F
05/31 03:20, 2F
文章代碼(AID): #1LQUwk2J (C_and_CPP)
文章代碼(AID): #1LQUwk2J (C_and_CPP)