Re: [鋼彈] hw 5-1
: 推 zvc1234455:可以請問一下你們判斷EOF是這樣寫的嗎? 11/04 17:17
: → zvc1234455:while (*gets(sentence) != EOF) 11/04 17:18
: → zvc1234455:sentence是矩陣. 我這樣寫輸入^Z會有問題耶 11/04 17:18
: → zvc1234455:但輸入文字可得正確答案 11/04 17:19
man gets 有關回傳值的敘述如下:
If end-of-file occurs before any characters are read, they
return NULL and the buffer contents remain unchanged.
也就是說讀不到東西的話 他會回傳NULL
*NULL...這東西應該沒定義吧 反正不會等於EOF(-1)
應該改成 while(gets(sentence)!=NULL)
或 while(gets(sentence))
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.51
推
11/04 18:24, , 1F
11/04 18:24, 1F
→
11/04 18:26, , 2F
11/04 18:26, 2F
→
11/04 18:27, , 3F
11/04 18:27, 3F
推
11/04 18:55, , 4F
11/04 18:55, 4F
絕對 沒有 修推文 嗄(?)
推
11/04 19:38, , 5F
11/04 19:38, 5F
※ 編輯: ianchou821 來自: 140.112.30.51 (11/04 20:04)
→
11/05 00:25, , 6F
11/05 00:25, 6F
→
11/05 18:23, , 7F
11/05 18:23, 7F
討論串 (同標題文章)