Feb 15, 2006 - Problem: convert pounds to kilograms ... The weight-converter program reading from the keyboard and writing to ... foo.open("data_report.txt");.
Computer Science I CS 135 3. File Input/Output a. Reading from the Keyboard b. Reading from an Input File c. Input & Output Streams 9 Streams are sequences of characters 9 Common streams: keyboard (cin) and screen (cout) 9 File streams: input files and output files
d. Writing to an Output File
2/15/2006
CS 135 - Computer Science I - 3. File Input/Output
27
3.c Input & Output Streams Streams are sequences of characters
¾ Streams 9 a stream is a sequence of characters from a source to a destination
2/15/2006
an input stream is a sequence of characters from an input device or a file to a program in the computer
an output stream is a sequence of characters from a program in the computer to an output device or a file
CS 135 - Computer Science I - 3. File Input/Output
28
3.c Input & Output Streams Streams are sequences of characters
¾ Extraction operator >> and insertion operator > reads characters from an input stream and groups them into meaningful data –72.6 – 7 2 . 6 e w ...
conversely, the insertion operator pounds;
// prompt user for weight in lbs cout > pounds;
// calculate weight in kilograms kilos = pounds / 2.2046;
// calculate weight in kilograms kilos = pounds / 2.2046;