06moreIO_3014

06moreIO_3014 - Lecture File 06 COP 3014 September 17, 2008...

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

View Full Document Right Arrow Icon
Lecture File 06 COP 3014 September 17, 2008 A. Ford Tyson 1 COP 3014 Lecture File 06 ± More about Input and Output 1 – File I/O – get and ignore functions – Buffered IO Copyright 1997-present, Ann Ford Tyson ± Two main types of files: text and binary ± Text file: comprised of ASCII characters examples ? Reading Input From Files & Other Input Options 2 ± Binary file: structure/contents determined by program which wrote the file examples ? files you type with Visual C++; files you type with pico, notepad; html files MSWord files, jpg, mp3 int main ( )<eoln> {<eoln> <tab>char ch;<eoln> Example Text File end of line marker 3 <tab>ch = 'X';<eoln> <tab>cout << ch ;<eoln> <tab>return (0);<eoln> }<eoln> <eof> end of file marker
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture File 06 COP 3014 September 17, 2008 A. Ford Tyson 2 ± #include <fstream> – contains data types ifstream , ofstream , and functions open and close ± Declare a file stream variable to Performing Basic Text file I/O 4 represent the file you intend to use ± Use new input file stream to read, and/or use new output file stream to write ± Close the file when done with it #include <fstream> input data output data File Input with Monitor Output 5 your file variable ( type ifstream ) cout ( type ostream ) disk file screen executing program 15 bb 5 b Q<eoln> <eof> Example: read from disk file 6 • again, b == one blank • assume that the file is named data.txt
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/14/2011 for the course COP 3014 taught by Professor Tyson during the Fall '10 term at FSU.

Page1 / 8

06moreIO_3014 - Lecture File 06 COP 3014 September 17, 2008...

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

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