[問題] cin的eof()問題
int main() {
int a=-1;
while(true) {
cin>> a;
if(cin.eof())
break;
}
cout<<a<<endl;
}
輸入 "1 ^z"
輸出卻是 -1
why ?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.91.181
推
02/03 02:33, , 1F
02/03 02:33, 1F
→
02/03 08:39, , 2F
02/03 08:39, 2F
→
02/03 11:49, , 3F
02/03 11:49, 3F
→
02/03 14:01, , 4F
02/03 14:01, 4F
推
02/03 21:19, , 5F
02/03 21:19, 5F
→
02/03 21:20, , 6F
02/03 21:20, 6F
→
02/03 21:32, , 7F
02/03 21:32, 7F
推
02/03 21:36, , 8F
02/03 21:36, 8F
→
02/03 22:05, , 9F
02/03 22:05, 9F
推
02/04 09:01, , 10F
02/04 09:01, 10F
→
02/04 09:19, , 11F
02/04 09:19, 11F
推
02/04 13:40, , 12F
02/04 13:40, 12F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章