User Input With cin Basics | C++ Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Thank You, your videos are calm, which help me to learn c++ every nicely

AloysiusDas
Автор

I had to include the <string> header before I could use the getline function. This is probably because I didn't follow the same setup in the previous videos.

cwill
Автор

I have gotten great information due to this channel.😀

yigitcoban
Автор

Hello! If we were to remove the above comments and run the whole program together, we would run into an unexpected outcome.

After we input the height and width, it won't let us enter the name and the program will end.

I found 2 ways to fix this, by adding cin.ignore(1000, '\n'); under the calculation of the area, or even exactly below the the
cin >> height >> width; . Is this correct and/or are these 2 ways different at all?

Edit: After many tests of my own, I understood that I'd probably need cin.clear() too inside an if statement, in case of a bad input. My question is the same though, are the 2 ways different?

phantom
join shbcf.ru