Q:

Segmentation Fault while malloc and sizeof

Sorry if I'm offending anyone but I started learning C this week and I got a segmentation fault while compiling this. Can I please have a second pair of eyes to help me with this error?
void Space(void *empty, size_p s)
{
    empty = malloc(s);
}

int main()
{
    int *p = NULL;
    Space(p, sizeof(p));
    *p = 7;

    return;
}

A:

empty is just a pointer variable - it contains "some" address, but it is still a local variable in the context of Space. If you want to update the value of int *p in Space, you'll need to pass a pointer to it:

int main()
{
    int *p = NULL;
    Space(&p, sizeof *p);
    *p = 7;

    return;
}

void Space(void **empty, size_p s)
{
    *empty = malloc(s);
}

Also, you have a bug where you call Space: Space(p, sizeof(p));
sizeof(p) is the size of the int * variable but you want to allocate the size of an int as that's what you're storing in p. So that line should instead be:
Space(&p, sizeof *p);

