I have a struct defined like this:
typedef struct foo {
void *bar;
int memory;
}
I'm trying to assign a value to the void-pointer like so:
int *mem = (int *)proc->memory;
proc->bar = mem;
However, the second line gives a segmentation fault. Why? I thought I knew how to use pointers but I don't.
after the assignment the mem pointer contains the address of proc->memory. But then when I try to assign the void *bar to that address, it says segmentationfault.
I've tried numerous stuff, introducing ampersands and pointercasts wherever, I have no clue what I'm doing.