xix
EXAMPLE
C++ By
VII Structures and File Input/Output
28 Structures..................................................583
Introduction to Structures.......................................................584
Defining Structures ..................................................................587
Initializing Structure Data.......................................................591
Nested Structures .....................................................................600
Review Questions.....................................................................603
Review Exercises ......................................................................604
Summary ...................................................................................604
29 Arrays of Structures ..................................605
Declaring Arrays of Structures...............................................606
Arrays as Members ..................................................................615
Review Questions.....................................................................623
Review Exercises ......................................................................624
Summary ...................................................................................624
30 Sequential Files.........................................625
Why Use a Disk?.......................................................................626
Types of Disk File Access ........................................................627
Sequential File Concepts .........................................................628
Opening and Closing Files......................................................629
Writing to a File ........................................................................635
Writing to a Printer ..................................................................637
Adding to a File ........................................................................638
Reading from a File ..................................................................639
Review Questions.....................................................................642
Review Exercises ......................................................................643
Summary ...................................................................................644
31 Random-Access Files ................................645
Random File Records ...............................................................646
Opening Random-Access Files...............................................647
The seekg() Function................................................................649
Other Helpful I/O Functions..................................................656
Review Questions.....................................................................658
Review Exercises ......................................................................658
Summary ...................................................................................659