Carlos Solís
Carlos Solís

Reputation: 55

What is an easy way to save a set of arrays to a file and back in C++?

I've been searching for an easy way with C++ to save a set of variables (in this case, a set of double arrays) to a file, and later load said file and get the set of variables.

Most of the ways that I've read about imply to lump all of the variables into a single array, or (even worse) write a custom class that reads and writes character by character, manually, all of which is impractical since the arrays will have variable length.

Is there a class or library that I could use? (The fact that I am asking this question means that, yes, it's one of the first times I have to deal with files in C++.)

Upvotes: 2

Views: 139

Answers (2)

Vaughn Cato
Vaughn Cato

Reputation: 64308

The boost serialization library is one option.

Upvotes: 1

abyss.7
abyss.7

Reputation: 14452

The protocol buffers may help: protobuf

Upvotes: 1

Related Questions