CS 150 Introduction to C++ Programming - Spring 1998 |
|---|
[ Home | Lecture Notes| WebTutor | WebTutor Site Map]
Standard input is extracted
cin, the standard input stream using the extraction
operator (>>).
When inputting a number, the extraction operator will
"search" for the number by skipping over any leading whitespace
(blanks and end of lines).
Input stops when an inappropriate character for that number type
is found.
Thus >> reads only as many characters from cin as
are needed to form a number.
Any characters after the number (including the character that
stopped the input) are still available for the next input
operation.
If you want to skip over some of the input, you can use the ignore operator. Ignore takes two arguments,
ignore will either ignore all input characters up to the maximum number or until a stop character is found, whichever comes first.
(see pages 141-142 in the textbook).