J
James
hello,
The program given below is giving segmentation fault. By debugging I
inferred that the problem is in the statement t1.f(), but I am not sure
that what is the problem.
#include <stdio.h>
struct type {
int i;
void (*f)(void);
};
void funct(void)
{
printf("this is funct\n");
return;
}
int construct(struct type t1,int i,void (*f)(void))
{
t1.i=i;
t1.f=f;
return 0;
}
int main(void)
{
struct type t1;
printf("This is main\n");
construct(t1,2,&funct);
t1.f(); // Most probably the problem is in this line.
return 0;
}
Can anybody please tell me that what is the real problem?
Thanks
The program given below is giving segmentation fault. By debugging I
inferred that the problem is in the statement t1.f(), but I am not sure
that what is the problem.
#include <stdio.h>
struct type {
int i;
void (*f)(void);
};
void funct(void)
{
printf("this is funct\n");
return;
}
int construct(struct type t1,int i,void (*f)(void))
{
t1.i=i;
t1.f=f;
return 0;
}
int main(void)
{
struct type t1;
printf("This is main\n");
construct(t1,2,&funct);
t1.f(); // Most probably the problem is in this line.
return 0;
}
Can anybody please tell me that what is the real problem?
Thanks