I have a static array in c defined like this:
typedef struct
{
int a;
int b;
int c;
int d;
} Hello;
static Hello hello[6] = {{0}};
then at some points I need to reset all the attributes of each elements in this static array to 0; how to do this?
You need to use
memset():Note that this only works since “all bits 0” is a pretty safe assumption for setting
intvariables to 0. Ifhellohad contained e.g.floats or pointers, that assumption doesn’t hold at all and you would have to do a manual loop.