Re: [問題] C fgets() 與陣列

看板C_and_CPP作者 (來不及了)時間13年前 (2010/10/09 02:57), 編輯推噓3(300)
留言3則, 3人參與, 最新討論串2/2 (看更多)
比較簡單的寫法,給大家參考:) #include <stdio.h> #include <string.h> int main() { int max =0; int i =0, j=0; int B[100]; char str[128]; FILE *fp; fp = fopen("mlist.txt","r"); while(fgets(str,4,fp) != NULL){ B[i] = atoi(str); printf("%d\n",B[i]); i++; } system("PAUSE"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.128.194.57 ※ 編輯: ny8656 來自: 140.128.194.57 (10/09 02:58)

10/09 03:13, , 1F
找到其他的答案還上來分享,推一個 XD
10/09 03:13, 1F

10/09 09:19, , 2F
:)
10/09 09:19, 2F

10/09 09:22, , 3F
再推!
10/09 09:22, 3F
文章代碼(AID): #1Chsc6M8 (C_and_CPP)
文章代碼(AID): #1Chsc6M8 (C_and_CPP)