Article 4SGDE callBack

callBack

by
subrahmaniam
from LinuxQuestions.org on (#4SGDE)
the error in below program is segmentation fault.
please can you suggest me how to resolve this issue. and is it correct method for a call back in c .
Thanks and regards,
K Subrahmaniam
#include <stdio.h>
#include<unistd.h>

typedef void (*CANFD_DataAppCallBack)( int reason);

typedef struct temp
{
CANFD_DataAppCallBack callBack;
} x;

static void mcancallBack(int reason)
{
printf("reason is %d\n",reason);
if(reason==0)
printf("This is callback\n");
}

int reason;
x *ptr;
int main()
{
reason =0;
ptr->callBack=mcancallBack;
return 0;
}latest?d=yIl2AUoC8zA latest?i=Luxx376iYbw:8La1i7od_Hg:F7zBnMy latest?i=Luxx376iYbw:8La1i7od_Hg:V_sGLiP latest?d=qj6IDK7rITs latest?i=Luxx376iYbw:8La1i7od_Hg:gIN9vFwLuxx376iYbw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments