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;
}


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;
}