I started to learn cpp and encountered cin as a way to receive input from the keyboard.
If I understood, cin is an object and >> is an operator defined for it.
In the way it is defined, how does it “knows” to separate words from each other?
and another thing,
what is the meaning of:
while(cin)
is cin a bool type? what does it mean if it returns true or false?
I started to learn cpp and encountered cin as a way to receive input
Share
Calling:
is equivalent to:
As far as your other question goes, in C/C++ anything that returns a
NULLor zero is treated as false in anifstatement, otherwise it is treated as true.That’s why the line:
if(cin)works to check whether there’s more data to be read in the stream.