B
brian
Quick question:
if I have a structure:
struct foo {
unsigned char *packet;
unsigned char *ip_src;
};
and another structure:
struct foo2 {
unsigned char *packet;
};
and I do:
struct foo *a;
struct foo2 *b;
a = malloc(sizeof(struct foo));
if (a == NULL)
return NULL;
(void)memset(a, 1, sizeof(struct foo));
b = (struct foo2 *)a;
--
Would foo2 just strip off the *packet?
And what happens to *ip?
I am trying to understand how C handles the typecast if
one structure pointed to has a different number of members
than the other. I am trying to understand how C99 treats
this situation. Both of my pointers should be correctly
aligned.
Thanks,
Brian
if I have a structure:
struct foo {
unsigned char *packet;
unsigned char *ip_src;
};
and another structure:
struct foo2 {
unsigned char *packet;
};
and I do:
struct foo *a;
struct foo2 *b;
a = malloc(sizeof(struct foo));
if (a == NULL)
return NULL;
(void)memset(a, 1, sizeof(struct foo));
b = (struct foo2 *)a;
--
Would foo2 just strip off the *packet?
And what happens to *ip?
I am trying to understand how C handles the typecast if
one structure pointed to has a different number of members
than the other. I am trying to understand how C99 treats
this situation. Both of my pointers should be correctly
aligned.
Thanks,
Brian