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
getline
getline
Jun 24, 2019 at 4:12pm UTC
DarkParadox
(32)
Hello,
When I use getline(cin,var) sometimes it is skipped.
Why is it skipped??
I know there is
cin.ignore();
, but it doesn't mean I must use it whenever I want to use getline() right??
Thanks..
Last edited on
Jun 24, 2019 at 4:12pm UTC
Jun 24, 2019 at 4:24pm UTC
lastchance
(6980)
If the stream is valid it is not skipped.
It may be called at a point when there is nothing of substance left in the buffer, so nothing of substance ends up in var.
The most common problems are a stream extraction (>>) followed by a getline.
I almost never use .ignore().
You need to show the code that you are having problems with.
Topic archived. No new replies allowed.