字符串輸入我在編程初學者,我寫了下面的代碼:關於用C
#include <stdio.h>
int main(void)
{
char x[] = "",
y[] = "",
z[] = "";
printf("Enter a string: ");
scanf("%s", x);
printf("Enter another string: ");
scanf("%s", y);
printf("Enter one more string: ");
scanf("%s", z);
printf("\n");
printf("x is %s\n", x);
printf("y is %s\n", y);
printf("z is %s\n", z);
getch();
return 0;
}
當我輸入「I」爲X「是」爲y和「快樂」爲Z,結果是這樣的:
x is ppy
y is appy
z is happy
有沒有人知道是什麼問題?謝謝!