Re: [問題] 一程式可讀入指定字串,輸出指定字串

看板C_and_CPP (C/C++)作者 (說好的年終呢~~~~)時間16年前 (2009/07/21 00:58), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《SiriusJinn (假斯汀)》之銘言: : int main(void) : { : char str[3][6]; : int i=0; : while(i<3) : { : scanf("%s",&str[i]); : printf("hello, %s\n",str[i]); : i++; : } : system("pause"); : return 0; : } 不需要每行都存起來吧 -.- int main() { char str[1024]; while(fgets(str, sizeof(str), stdin)) printf("hello, %s", str); // 這裡不要印 \n,因為 str 已經含有 \n return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.64.207.103
文章代碼(AID): #1APA8xcR (C_and_CPP)
文章代碼(AID): #1APA8xcR (C_and_CPP)