Assume I have an array which holds some struct defined as follows:
static struct s x[10]
Is each element in the array initialized or are they all empty slots?
In another words, what happens if I do:
struct s {
struct s *next;
};
struct s a;
a.next = &x[0];
x[0].next = &x[1];
Would a‘s next point to x[0] and x[0]‘s next point to x[1]?
Yes, this would work just fine. Sounds like you’re thinking about Java arrays. In C, if you declare an array of some type, the actual objects are in the array, not just (uninitialized) references to objects.