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正常工作?谢谢