cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Explanation cin
Explanation cin
Dec 3, 2016 at 1:19pm UTC
Day Vide
(37)
Can you guys explain what the difference is ? Thanks
std::getline(std::cin, input);
std::cin >> input;
Dec 3, 2016 at 1:38pm UTC
Aceix
(1118)
getline reads from the input buffer till it encounters a newline character(by default, can be changed).
cin on the other hand reads input till a whitespace character is met.
Dec 3, 2016 at 1:56pm UTC
Day Vide
(37)
Oh ok thanks mate
Dec 3, 2016 at 1:59pm UTC
Chervil
(7320)
Remember cin >> first ignores leading whitespace, but getline does not.
Dec 3, 2016 at 2:38pm UTC
boost lexical cast
(395)
Also,
std::getline()
is better for strings.
Topic archived. No new replies allowed.