Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does cin.clear() clear the input buffer?

Tags:

c++

io

cin

From what I have read, cin.clear() resets the flags, but how does this clear the input buffer?

like image 779
Bbvarghe Avatar asked Mar 22 '23 04:03

Bbvarghe


1 Answers

cin.clear() has no effect on the input buffer. As you correctly read, it resets the iostate flags (technically, replaces their current value with std::ios_base::goodbit)

like image 109
Cubbi Avatar answered Mar 31 '23 12:03

Cubbi