w*****j 发帖数: 49 | 1 if i wrote something like while(cin>>n){...}
how do i hit enter to let the loop end? |
d****p 发帖数: 685 | 2 you can hit ctrl-D then enter to quit the loop.
However, this is bad code.
Use cin.get() or cin.getline() instead of cin>> if you don't know
how many times you are gonna read. |
w*****j 发帖数: 49 | 3 thanks, but if i use cin.get(), will cin get a charactor or a float or what?
how can i control that?
know
【在 d****p 的大作中提到】 : you can hit ctrl-D then enter to quit the loop. : However, this is bad code. : Use cin.get() or cin.getline() instead of cin>> if you don't know : how many times you are gonna read.
|
X****r 发帖数: 3557 | 4 "get()" extracts *unformatted* data from the stream as character
or characters.
You seem to have lots of questions on istream. Why don't you just
read through the document for once? It only takes 15 minutes and
it would save lot of your time on these questions.
what?
【在 w*****j 的大作中提到】 : thanks, but if i use cin.get(), will cin get a charactor or a float or what? : how can i control that? : : know
|