Hi
I have written a function where I can save a structure in a file. So the prototype looks like this:
Code:
void SaveStructure(FILE *f, STRUCTURE *structure);
The structure looks for example like this:
Code:
typedef struct
{
int dummy;
char text[30];
} STRUCTURE ;
Now I want to use the function SaveStructure(...) again, but with this structure for example:
Code:
typedef struct
{
int nr;
char name[30];
char street[30];
} NEW_STRUCTURE ;
How can I make it possible that the function SaveStructure(...) doesn't care how the structure looks like?
Does the format of the pointer struct always looks the same? So could I make a dummy-structure:
Code:
typedef struct
{
int dummy
} SAVESTRUCT;
and use the function:
Code:
void SaveStructure(FILE *f, SAVESTRUCT *structure);
this way?
Code:
void main (void)
{
FILE *f1 = NULL;
FILE *f2 = NULL;
STRUCTURE structure;
NEW_STRUCTURE new_structure;
SaveStructure(f1, &structure);
SaveStructure(f2, &new_structure);
return;
}
thx for any help....