Why use cin.get while cin>> seems fine | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 19

Why use cin.get while cin>> seems fine

am still a begginer...dont get all geeky🙄🙄

10th Aug 2017, 11:19 AM
Lawrence Muema (😳😌)
Lawrence Muema (😳😌) - avatar
2 Answers
+ 13
cin.get extracts characters from the input stream and store them as a c-string. http://www.cplusplus.com/reference/istream/istream/get/
10th Aug 2017, 11:30 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
cin.get() is a built-in method with three overloads, purposely for character inputs. it reads every character you enter including space and newline. the stream extraction operator >> is overloaded for any type, and can also be overloaded for user-defined types. it terminates on reaching a space or newline on input.
13th Aug 2017, 2:21 PM
Germain F
Germain F - avatar