Hi! I want to have a function pointer inside a typedef struct but I get a segmentation fault when I run my code. Here's my code:
ThanksCode:#include <stdio.h> typedef struct Foo { void (*bar)(int); } Foo; void func(int x) { printf("display: %d\n", x); } int main() { Foo* foo = NULL; foo -> bar = &func; foo -> bar(1); return 0; }