如果我在scanf語句中提供字符串「Alice in wonder land」,下面的代碼的輸出(底部的代碼)是什麼?我的書上說的輸出應該是:做空格將字符串分隔成不同的字符串?
Alice
in
wonder
land
好吧,如果我已經提供了「愛麗絲驚奇地」作爲一個字符串,爲什麼是這樣的輸出?當我將「愛麗絲夢遊仙境」作爲一個單獨的字符串提供時,如何在「愛麗絲」,「在」,「奇蹟」,「土地」之間提供空格使它們分開的字符串?
#include<stdio.h>
void main()
{
char s1[10], s2[10], s3[10], s4[10];
scanf("%s%s%s%s", s1, s2, s3, s4);
printf("\n%s\n%s\n%s\n%s", s1, s2, s3, s4);
getch();
}
謝謝! :)
1)它不會編譯,如果你嘗試和2)你爲什麼不嘗試? – JRG
你可能需要一個很好的C教程 – P0W
@AdrianJandl在連續%s之間沒有空格 – lebowski