11.3 FORMAT-FREE INPUT
Let us study it in terms of various basic data types.
(1) Reading Integers
In C++, cin is the standard stream object for input. It is usually associated with the keyboard. The binary extraction operator >> is used for reading (input). Some books call it input operator. It takes cin as left-hand-side operand and a variable to be read as right-hand-side operand. A statement like
cin >> marks ;
reads marks for us. It is like scanf(“%d”, &marks) ; This statement1 does the following: it tells the computer to read the value of marks from stream cin. Note the ease of operations compared to old C language. We do not have to specify or tell that variable “marks” is an integer. We do not need ‘&’operator around marks. When you execute ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access