[   ^ to index...   |   <-- previous   |   next -->   ]

Using input streams

To read input from a stream, we use the >> operator:

int i; char b[30]; cin >> i; // Reads an int from standard input cin >> b; // Reads a "word" from standard input

Any amount of leading whitespace will be skipped. Reading into a char array is interpreted as "read word". A "word" is a sequence of non-whitespace characters.

About the >> operator

>> is a binary operator, just like addition (+). It has the following odd properties, which do not seem so odd when you consider that other operators are just as odd:


Last modified: Wed Jun 28 20:42:03 PDT 2000