Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
May 23, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Data Files Help

I am teaching an introductory C++ course at the high school level. My textbook briefly covers data 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?

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.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date