#include <stdio.h>
#include<stdlib.h>
#include <string.h>
int main(void) {
char a[1001];
int t,i;
scanf("%d",&t);
while(t--)
{
fflush(stdin);
gets(a);
printf("%d\t",t);
puts(a);
}
return 0;
}
輸入:如何輸入兩個字符串?
2
die another day.
i'm batman.
輸出繼電器:
1
0 die another day.
預期輸出:
1 die another day.
0 i'm batman.
請人幫忙如何接受沒有任何錯誤不止一個字符串。 進入2後,我能夠看到我的get獲取換行符作爲第一個字符串,然後第二個字符串正確。 在此先感謝
技術上'fflush(stdin)'是未定義的行爲。它在所有系統和平臺上都不受支持。 –
任何想法都可以使程序在幾乎編譯器上正常工作?包括在線編譯器。 –