I want to change an CONST function pointer after it's initialed, I tried the following, i printed the pointer address copyed by memcpy, the address is different from the function address. Also, I get a seg fault on executing it. How can i do this?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void function(void){
}
const void (*function_pointer)(void)=NULL;
int main(){
memcpy(&function_pointer, &function, sizeof(fuction_pointer));
fprintf(stderr, "%p, %p\n", &function_pointer, &function);
function_pointer();
return 0;
}