Lecture09 - Lecture 09 File I/O and Intro to Iteration...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Engineering 101 Engineering 101 Lecture 09 Lecture 09 File I/O and Intro to Iteration File I/O and Intro to Iteration Prof. Michael Falk University of Michigan, College of Engineering
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Announcements Announcements Project 2 Due Tonight at 9pm Exam 1 will be held Wednesday 10/4 from 7-9pm, room assignments to be announced. Sample Exams are now posted. Early Exam 1 Mon 10/2 from 3-5pm in Dow 1017. Contact me by Wednesday if you need to take the early administration. Alfred Chung Ruixuan Wang Zac Evans-Golden Ramsey Hilton MaryAnn Winsemius Derek Geiger Alexandra Holbel Kyle Polack Taylor Santiago Randy Tin Jeffery Mortimer Dave Retterath Rob Keim
Background image of page 2
Announcements Announcements Project 1 returned yesterday and today. Submit any regrade requests to your GSI in writing within one week.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
More About Streams More About Streams We already introduced input streams and output streams in the context of talking about cin and cout . cin is standard input and we have used this to get input from the keyboard. cout is standard output and we have used this to send output to the screen.
Background image of page 4
More About Streams More About Streams You (the user) The computer OS Your Executable cin cout
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
More About Streams More About Streams There are two other output streams we can access through the iostream library. cerr is standard error. clog is standard log. cout and clog are buffered , the output does not go directly to the screen. cerr is not buffered. cout is tied to cin . Whenever cin is used the cout buffer is “ flushed ”.
Background image of page 6
More About Streams More About Streams You (the user) The computer OS Your Executable cin cout clog cerr
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Using Unix (Linux) You Can Redirect Using Unix (Linux) You Can Redirect I/O To Files I/O To Files red% myprogram < inputfilename Reads the input from an input file instead of the keyboard. You can choose any filename. red% myprogram > outputfile Sends the output to an output file instead of the screen. Again the filename is up to you. red% myprogram < inputfile > outputfile
Background image of page 8
Better Ways To Use Files Better Ways To Use Files This trick of piping the standard output to a file or the standard input from a file will not work if you want to communicate using the keyboard, screen AND files. If we include the fstream library by typing #include <fstream> then we can define new streams that can get input from and direct output to files.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The fstream Library The fstream Library fstream adds two new types: ifstream and ofstream . These stand for input file stream and
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 43

Lecture09 - Lecture 09 File I/O and Intro to Iteration...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online