Data Files Help

Question:
I am teaching an introductory C++ course at thehigh school level. My textbook briefly coversdata files–sequential access–but doesn’t provide many examples of how to write/read multiple variables. Where would be a good place to look for example programs?

Answer:
I suspect that the reason your textbook doesn’t go into much detail is because the variations are virtually endless.

One approach is simply to store data as a series of structures and calculate the offset of a specific structure and read it in to obtain that record.

But that’s only one way. You could store data the same way but read the entire file into memory and save it all at once. In many cases, records may not be the same length; then you need to implement some sort of index that indicates where each record starts.

In short, I’ve personally spent many hours looking at code variations of data file access. But when you ask for examples, I really have to determine what sort of data file makes most sense for you.

I would check your local computer bookstore. Perhaps you can find a book on algorithms or file access that would be helpful.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: