Search:
Forum
Beginners
Program is skipping cin.getline in loop?
Program is skipping cin.getline in loop?
Mar 24, 2015 at 7:36pm UTC
ChillMick
(15)
...
Last edited on
Mar 31, 2015 at 6:48pm UTC
Mar 24, 2015 at 7:44pm UTC
Aceix
(1118)
you probably need to ignore any character in the input stream by using cin.ignore() just before the cin.getline() statement.
Aceix.
Mar 24, 2015 at 7:46pm UTC
TarikNeaj
(2580)
First of all. Why are you using a character array, and then keep saying string string string, instead of just using
std::string
?
To fix your problem. Try putting a
cin.ignore();
just above your cin.getline
Last edited on
Mar 24, 2015 at 7:47pm UTC
Mar 24, 2015 at 7:53pm UTC
mgoetschius
(96)
just put
cin.sync()
on line 52.
Mar 24, 2015 at 8:07pm UTC
MiiNiPaa
(8886)
just put cin.sync() on line 52.
Bad advice:
1) Does not on every platform
2) Even on Windows it depends on many settings (including common one which speeds up streams considerably and is often used)
Mar 24, 2015 at 8:16pm UTC
mgoetschius
(96)
Thanks, and noted for myself. I retract my suggestion.
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs