0
看起來是一個老問題,但這裏的問題不是使用兩個cin.get(),而是兩個以上的!如果我寫(在DEV C++)
我只得到一個輸入請求,然後結束程序。現在,我希望有CIN的至少兩個請求,因爲我預計:C++多個cin.get()
char s[50];
char t[100];
char r[100];
char f[100];
cin.get(s,49);
cin.get(t,99);
cin.get(r,99);
cin.get(f,99);
我expeted至少2個輸入請求,這是因爲:
first cin: buffer empty,I insert the string s and \n
second cin: I have in buffer \n still, then t=\n without input request
third cin: buffer empty, I insert the string r and \n
fourth cin: I have in buffer \n still, then f=\n without input request
但我只是s字符串輸入請求! 爲什麼我只有一個輸入請求?緩衝區沒有用第二個cin.get清理,讓第三個cin.get正常工作?謝謝