multiple structures in a file c
<p>I need to save a file that contains multiple structure data but not in a defined order. </p>

<p>Sample structs: </p>

<pre><code>typedef struct {
   int a;
   char b;
} StructA_t;

typedef struct {
   CUSTOM_t a;
   char *b;
} StructB_t;

typedef struct {
   long a;
   short b;
} StructC_t;
</code></pre>

<p>The file contents struct:</p>

<pre><code>typedef struct {
   int iStructType; // how can I get this??
   void *vpStructDatas;
   char *pNextStruct; // not necessary, can be calculated with sizeof()
} FileStruct_t;
</code></pre>

<p>sample file content:</p>

<pre><code>[StructA identifier][StructA data][StructC identifier][StructC data]
</code></pre>

<p>or:</p>

<pre><code>[StructB identifier][StructB data]
</code></pre>

<p>every combination (even multiple definitions of a type) needs to be possible by using something like this.</p>

<p>Like this, I want to save and read multiple structures in a file dynamically.</p>

<p>Can something like this be achieved?</p>

<hr>

<p><strong>Update:</strong> If I use struct labels as ID's or names, </p>

<p>How may I write the real struct to the file, not the pointer and after reading, how should I act? Will I need to create these read data structs globally in the memory?</p>

<hr>

<p>To prevent misunderstanding, I'm going to save the data that structures contain to a file. Not the struct definition.</p>