#10838: __c解


35133732 (TW藍風●w●)


#include<stdio.h>
int main() {
char s[9999];
while( scanf("%s",s)!=EOF ) {
printf("hello, %s\n",s);
}
return 0;
}

#11278: Re:c解


kenny191971 (kenny)


#include
int main() {
char s[9999];
while( scanf("%s",s)!=EOF ) {
printf("hello, %s\n",s);
}
return 0;
}

大大請問一下,為什麼在此提我們要宣告字元陣列有9999個位?
我的程式碼也跑得起來如果只用1,對不起我是C新手哈哈,請大大開釋一下喽。

謝謝你

#14805: Re:c解


happyman940815@gmail.com (【百鬼組】希格瑪 - 一位排球廢物高中生)


#include
int main() {
char s[9999];
while( scanf("%s",s)!=EOF ) {
printf("hello, %s\n",s);
}
return 0;
}

大大請問一下,為什麼在此提我們要宣告字元陣列有9999個位?
我的程式碼也跑得起來,如果只用1,對不起我是C新手哈哈,請大大開釋一下喽。

謝謝你

char s[9999]是指可以放9999個字元

用以的話只有s[0]可以存放

例:string→s

所以...你這題就部會過了