11.4 FORMATTED INPUT

An operator at the console is unlikely to enter data which appears formatted. In general, formatted input will come from a file. We will be discussing files in Chapter 14 “File Handling”. It is perceived that reading from file or reading from console is more or less identical.

The term Formatted Input reminds us of the story of a great scientist Newton. He dug a big and a small hole for his cat and kitten. He was forgetful of the fact that kitten can enter through the bigger hole meant for the cat. It is comfortable to have a system which can read format-free input as well as formatted input. In general, the statement

cin >> x >> y ;

will read x and y whether input is formatted or unformatted. See Program 11.4.

Problem:

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.