J
JS
I give a function a void pointer as an argument. But in the function I would
like to treat this argument as an integer (only pointers to integers will be
sent to the function) therefor I would like to cast it into an int pointer.
I found the following example:
void use_int(void *r) {
int a;
a = * (int *) r;
printf("As an integer, you are %d years old.\n", a);
}
but I don't get this line:
a = * (int *) r;
does it mean that a is a pointer to a pointer??
like to treat this argument as an integer (only pointers to integers will be
sent to the function) therefor I would like to cast it into an int pointer.
I found the following example:
void use_int(void *r) {
int a;
a = * (int *) r;
printf("As an integer, you are %d years old.\n", a);
}
but I don't get this line:
a = * (int *) r;
does it mean that a is a pointer to a pointer??