0

Izzy the Iguana

Hey guys I need some help with my code for Izzy. When I set my food string manually to the 2nd test case it works but when I got it via cin it won't work. Can anybody tell me why? :) https://code.sololearn.com/cgpWo8g9uDX1/?ref=app

11th Mar 2023, 7:58 PM
Kodokuu Mikadzuki
Kodokuu Mikadzuki - avatar
4 Respostas
+ 1
If you want to read a whole line that contains white spaces, try to use getline()
11th Mar 2023, 8:21 PM
Lisa
Lisa - avatar
+ 1
Replace line 12 with getline(cin, food); The blank spaces break the input stream so only the first Carrot was read when using cin >> food;
11th Mar 2023, 8:08 PM
Lisa
Lisa - avatar
0
nice thanks :)
11th Mar 2023, 8:11 PM
Kodokuu Mikadzuki
Kodokuu Mikadzuki - avatar
0
Lisa so its better to use getline() for strings?
11th Mar 2023, 8:20 PM
Kodokuu Mikadzuki
Kodokuu Mikadzuki - avatar