I have a struct defined in my program as:
struct memregion {
void *from;
void *to;
int mode;
}
I declare in my program, an array of this struct as struct memregion regions[10]. Then I pass it to a function as get_mem_layout(regions, 10) whose declaration is:
void get_mem_layout(struct memregion *regions, int size)
However, when I try to write data to any member variable of the struct as
regions[j].mode = 1;
OR
void *addr;
addr = (void *)0;
regions[j].from = addr;
I receive a segmentation fault. I cannot determine why this is happening. Please help.
UPDATE: Full code removed because it was part of an assignment. Problem was resolved through @paddy's answer.
j < size? - chrisaycockj? - asgsNULLtoregions[n].from? - Ed S.