I started out with a simple idea.
I have one struct with things i need to modify inside
typedef struct {
int stuff;
int things;
unsigned long long store;
} line;
and I need to make a 2d array of these structures, dependent on two other numbers that have already been read in and initialized. Yet when I try to just create
line book[X][Y];
I segfault all over the place.
I know i need to use malloc but no matter what I try I can't seem to make this work!
How do I achieve my goal? I really just need help understanding malloc, its such a foreign concept. If someone could help me out that would be amazing.
line book[X][Y];is fine (up to a certain size). If you get segfaults it may be because there are problems in the rest of your code. Further, if you do decide to use malloc then you don't need to use multiple malloc calls; a single malloc is fine.