Should I use a condition like "std::cin.peek() != '\n'" for loops to catch cin extraneous input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Should I use a condition like "std::cin.peek() != '\n'" for loops to catch cin extraneous input?

I've an example code posted in my profile named "Console Calculator for any number of input". Could such usage be a bad practice?

3rd Apr 2019, 11:30 AM
Nay Wunna Zaw
Nay Wunna Zaw - avatar
2 Answers
+ 1
Theres more than one way tp get a job done. If your just learning and practicing, maybe leave it alone. And later on come back and update?
10th Apr 2019, 1:42 AM
Erick Gonzalez
Erick Gonzalez - avatar
0
no dont do that
13th Apr 2019, 6:12 PM
austin
austin - avatar