4. File Streams - File Streams ENGR 101 Lecture 4 20 Sep 10...

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

View Full Document Right Arrow Icon
1 File Streams ENGR 101, Lecture 4: 20 Sep 10 Announcements Project 2 is due Wednesday night at 9pm More on the project later in this lecture…
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Streams Input Stream Output Stream Source of data, accessed incrementally In C++, accessed by extraction operator ( >> ) C++ standard input: cin Destination for data, presented incrementally In C++, presented by insertion operator ( << ) C++ standard input: cout Sequences of data made available over time element by element Files Basic units of persistent information maintained by an operating system Organized in a file system, with file names and (typically) hierarchical directories Pathname: specifies sequence of contained directories, culminating in file name Examples: /afs/umich.edu/user/w/e/wellman/engr101/myprog.cpp ~/engr101/myprog.cpp
Background image of page 2
3 The fstream Library 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 . fstream adds two new types: ifstream and ofstream . stand for input file stream and output file stream subtypes of istream and ostream , so they can be used just like cin and cout ostream cout operations : << C++ Stream Types istream cin operations : >> ifstream ofstream
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Reading from Files To read from a file you first must declare a new ifstream
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/25/2011 for the course ENGR 101 taught by Professor Ringenberg during the Fall '07 term at University of Michigan.

Page1 / 9

4. File Streams - File Streams ENGR 101 Lecture 4 20 Sep 10...

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

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