I'm learning C and I've found something like that.
#include <stdio.h>
void func(int* y) {
int x = 1;
*y = 2;
y = &x;
}
int main(int argc, char** argv) {
int x = 3;
int* x_ptr = &x;
printf("Value before call: %d\n", x);
printf("Pointer before function call: %p\n",(void*)x_ptr);
func(x_ptr);
printf("Value after call: %d\n", x);
printf("Pointer after function call: %p\n",(void*)x_ptr);
return 0;
}
I don't know why (void*)x_ptr int* casting is used. Why use int* to void* casting? Thank you for any help.