Re: What u mean by this statemnet ?.
- From: Michael Mair <Michael.Mair@xxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 08:53:40 +0100
Umesh wrote:
what this statement &(*IR)->func means.
where IR is the pointer to structure & func is pointer to fuction. func is the member of structure.
a->b is the same as (*a).b. Thus, IR cannot be a pointer to struct but is a pointer to a pointer to struct, as it is dereferenced twice: (*IR)->func means (**IR).func Now, you apply the address operator. This gives you the address where the function pointer (**IR).func is stored.
Observe:
#include <stdio.h>
int main (void)
{
struct test {
int filler;
void (*func)(void);
} instance, *pinst, **IR;
int offset = offsetof(struct test, func);instance.filler = 0; instance.func = NULL; pinst = &instance; IR = &pinst;
printf("inst: %p func: %p %p\n", (void *)(&instance),
(void *)(&instance.func), (void *)(&(*IR)->func));
printf("distance: %d %d\n", (int) offset,
(int) ((unsigned char*)(&(*IR)->func)-(unsigned char*)(*IR)));return 0; }
Cheers Michael -- E-Mail: Mine is an /at/ gmx /dot/ de address. .
- Follow-Ups:
- Re: What u mean by this statemnet ?.
- From: Umesh
- Re: What u mean by this statemnet ?.
- References:
- What u mean by this statemnet ?.
- From: Umesh
- What u mean by this statemnet ?.
- Prev by Date: Re: union
- Next by Date: Re: union
- Previous by thread: Re: What u mean by this statemnet ?.
- Next by thread: Re: What u mean by this statemnet ?.
- Index(es):
Relevant Pages
|