I've tried writing this code and the two printf statements appear to give segmentation fault. why isn't the output 5? what went wrong? and how to edit this code in a way such that it prints 5?
#include <stdio.h>
int* fun(int x){
    x=5;
    return &x;
}
int main() {
    int x = 3;
    int* p = fun(x);
    printf("%d",*(fun(x)));
    printf("%d",*p);
    return 0;
}
 
    