I am currently saving and loading some data into C / C ++ structures in files using fread () / fwrite (). This works great when working in this C application (I can recompile whenever the structure is changed to update the sizeof () arguments for fread () / fwrite ()), but how can I load this file into other programs without knowing sizeof in advance () s of structure C?
In particular, I wrote this other Java application that visualizes the data contained in this binary C struct binary, but I would like to get a general solution on how to read this binary. (Instead of manually inserting me into sizeof () s into the source of the Java application whenever the C structure changes ...)
I'm thinking of serializing for text or XML of some kind, but I'm not sure where to start (how to serialize in C, then how to deserialize in Java and possibly other languages in the future), and if appropriate here, when one member of the structure is a floating-point array that can grow up to ~ 50 MB in binary format (and I have hundreds of these data files for reading and writing).
The structure of C is simple (there are no strict references to nesting or a pointer) and looks like this:
struct MyStructure { char *title; int id; int param1; int param2; float *data; }
The part that can change the majority are param integers.
What are my options here?
java c xml serialization
arcanex
source share