int d() {return 0;} int i() {return 7;}
struct a { int(*b)(); }c={d};
typedef struct e{ struct a f; }g;
main() { struct e *h; h->f.b = i; }
I am getting segmentation fault when I try to run this program. Can anyone justify the reason?
And I also tried like
int d() {return 0;} int i() {return 7;}
struct a { int(*b)(); }c={d};
typedef struct e{ struct a f; }g;
main() { struct e *h; h = (g)malloc(sizeof(g)); h->f.b = i; }
Now I am getting errors like
funptrinstrct.c: In function `main': funptrinstrct.c:17: error: conversion to non-scalar type requested
Answer for this also would be appreciable.