i have a function which creates an array of pointers to a struct like:
Code:
node *fn()
{
node *buf[MAX];
<other code here>
printf("buf:%d\n",buf[0]->num);
printf("buf:%d\n",buf[0]->next->num);
printf("buf:%d\n",buf[1]->num);
printf("buf:%d\n",buf[1]->next->num);
return *buf;
}
main()
{
node *control=fn();
printf("%d\n",control->num);
printf("%d\n",control->next->num);
control++;
printf("%d\n",control->num);
printf("%d\n",control->next->num);
}
the problem is my printf's from main and from f() do not match..i do not understand why. The ones I see from f() are correct but the ones from main are not. why is this?