0

When do you use the getline?

i have been watching videos on C++ and some ask for user input with cin >> variable and some use getline (cin, variable) Is there a difference and when woukd you uae one rather than the other. Thank you.

22nd Jul 2017, 9:19 PM
Richard Appleton
Richard Appleton - avatar
2 Antworten
+ 4
getline => getting line: exp char* "my name is chokri" => cin getting first string: just "my" word. Thanks.
22nd Jul 2017, 9:32 PM
Chokri ZAGROUBA
Chokri ZAGROUBA - avatar
+ 2
getline gets the entire line, while cin only gets the letters/numbers up until it encounters a space or the line ends
22nd Jul 2017, 10:18 PM
aklex
aklex - avatar