#define MAX 100
struct bs{
int ab;
int ac;
}be;
struct s{
be b;
int c;
int d;
int e;
}fe;
int a[MAX];
fe f;
Technique 1:
f.b.ab = a;
memset(&a,0,sizeof(a));
f.b.ac = MAX;
Technique 2:
f.b.ab = a;
f.b.ac = MAX;
memset(&a,0,sizeof(a));
Technique 3:
memset(&a,0,sizeof(a));
f.b.ab = a;
f.b.ac = MAX;
which is the best technique to follow and why?
Technique 3:
because both
aandfb.b.abwill have clear memories with only onememset()call. Any other kind of optimization you might been hoping for is insignificant.