This is an example of what my code looks like:
void *a = NULL;
void *b = //something;
a = (void *)(*((char *)b + 4));
The value that (b+4) is pointing to is an address that I want to store in a. When I try to compile, I get “warning: cast to pointer from integer of different size.” What does this mean, and what should I do to fix it?
EDIT: To clarify, I don’t want ‘a’ to point to an address that is 4 bytes greater than ‘b’. In my program, I know that the value stored at ((char *)b + 4) is itself another pointer, and I want to store this pointer in ‘a’.
This is a
char*:That means that this:
is a
char. Then you proceed to cast thatcharto avoid*and the compiler complains. You don’t have to manually cast tovoid*in C so just this should do:Update for comments: Sounds like you’re after this: