Assume I have a static array of structures the elements of which
could be any conceivable mixture of C types, pointers, arrays.
And this array is uninitialized at program startup.
If later in the program I wish to return this array to its
startup state, can this be accomplished by writing binary
zeroes to the entire memory block with memset(). E.g.,
static struct mystruct_st {
int x1;
int *x2;
double x3[10];
- - -
} myarray[20];
/* Do things with myarray */
- - -
/* Restore initial myarray */
memset(my, 0, sizeof(myarray) );
(where "- - -" indicates other valid code)
Or do the initial values of the elements depend on the
version or implementation of C?
Thanks for your help.
Regards,
Charles Sullivan
could be any conceivable mixture of C types, pointers, arrays.
And this array is uninitialized at program startup.
If later in the program I wish to return this array to its
startup state, can this be accomplished by writing binary
zeroes to the entire memory block with memset(). E.g.,
static struct mystruct_st {
int x1;
int *x2;
double x3[10];
- - -
} myarray[20];
/* Do things with myarray */
- - -
/* Restore initial myarray */
memset(my, 0, sizeof(myarray) );
(where "- - -" indicates other valid code)
Or do the initial values of the elements depend on the
version or implementation of C?
Thanks for your help.
Regards,
Charles Sullivan
Comment