typedef struct
{
int data;
int size;
} s1;
typedef struct
{
char data;
int size;
} s2;
typedef struct
{
float data;
char size;
} s3;
func(void *p)
{
/*this should be generic to all structure.*/
/* Need to do for removing duplicate codes*/
/* p->data=1; p->size=0; this should be generic */
}
int main()
{ s1 a;s2 b; s3 c;
func(a);func(b);func(c);
}
Here need to initialize this structure is random. Requirement is to keep "func" as a common function for all structure type.
Please suggest optimum method in C and not in C++