LectureTen - C+ Programming Lecture 10 File Processing By...

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

View Full Document Right Arrow Icon
Lecture 10 File Processing By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department
Background image of page 1

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

View Full DocumentRight Arrow Icon
The Hashemite University ٢ Outline ± Introduction. ± The Data Hierarchy. ± Files and Streams. ± Creating a Sequential Access File. ± Reading Data from a Sequential Access File. ± Updating Sequential Access Files. ± Input/Output Manipulations. ± Examples.
Background image of page 2
The Hashemite University ٣ Introduction ± Data files can be created, updated, and processed by C++ programs ± Files are used for permanent storage of large amounts of data ± Storage of data in variables and arrays is only temporary
Background image of page 3

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

View Full DocumentRight Arrow Icon
The Hashemite University ٤ The Data Hierarchy I ± Bit - smallest data item ± value of 0 or 1 ± Byte – 8 bits ± used to store a character ± Decimal digits, letters, and special symbols ± Field - group of characters conveying meaning ± Example: your name ± Record – group of related fields ± Represented as a struct or a class ± Example: In a payroll system, a record for a particular employee that contained his/her identification number, name, address, etc. ± File – group of related records ± Example: payroll file ± Database – group of related files
Background image of page 4
The Hashemite University ٥ The Data Hierarchy II ± Record key ± identifies a record to facilitate the retrieval of specific records from a file ± Sequential file ± records typically sorted by key 1 01001010 Judy Judy Green Sally Black Tom Blue Judy Green Iris Orange Randy Red File Record Field Byte (ASCII character J) Bit
Background image of page 5

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

View Full DocumentRight Arrow Icon
The Hashemite University ٦ Files and Streams ± C++ views each file as a sequence of bytes ± File ends with the end-of-file marker ± Stream is created when a file is opened ± File processing ± Headers <iostream> and <fstream> ± class ifstream - input ± class ofstream - output ± class fstream - either input or output
Background image of page 6
The Hashemite University ٧ Creating a Sequential Access File ± Files are opened by creating objects of stream classes ifstream , ofstream or fstream ± File stream member functions for object file : ± file.open(“Filename”, fileOpenMode ); ± file.close(); ± closes file ± File open modes: Makes a "line of communication" with the object and the file. Mode
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

LectureTen - C+ Programming Lecture 10 File Processing By...

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

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