- Reference
- This operator has a target
-
cin >> target
- The type of the target determines how the operator works.
- In general
-
skip all whitespace until a non-whitespace character is encountered.
while the next character is part of a valid target
extract the character and add it to the new input value.
If valid data was read
set the target to the new input value
else
set the stream in a state of error
- What will happen
-
int i;
cin >> i
stream
------------
1 2 3 4 _ ...
-
int i;
cin >> i
stream
------------
1 2 . 3 4 _ ...
-
int i;
cin >> i
stream
------------
1 2 + 3 4 _ ...
-
int i;
cin >> i
stream
------------
+ 1 2 3 4 _ ...
-
int i;
cin >> i
stream
------------
s 1 2 3 4 _ ...
- How would this be different for characters?
- How would this be different for strings?
- How would this be different for floats?