cin vs getline vs cin.getline

摹慭 25 ć››æœˆ 2020
By fx-moon

cin vs getline vs cin.getline

Case with '\n'

cin

drop all `'\n'` except last one (just leave it in the buffer,won't get it and will finally drop it).

getline

read until `'\n'` and replace `'\n'` with `'\0'`.

cin.getline

same with getline, replace `'\n'` with `'\0'`.

but used for c_string.

Pages