Re: sizeof a union
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 20:28:39 +0000
pemo wrote:
<snip why is the size of a struct
Why not add another member and use that to 'explore' the other members,
Any results are highly implementation specific, of course.
e.g.,:
#include <stdio.h>
typedef union { int x;
struct { int a; int b;
<snip>
int main(void) { SU a;
printf("x = \t%p\n", &a.x);
If using %p you should cast the pointer to void* printf("x = \t%p\n", (void*)&a.x);
printf("y.a = \t%p\n", &a.y.a);
Also, for this sort of thing using the offsetof macro from stddef.h would be more useful.
<snip> -- Flash Gordon Living in interesting times. Although my email address says spam, it is real and I read it. .
- References:
- Re: sizeof a union
- From: pemo
- Re: sizeof a union
- Prev by Date: Re: direct string manuplation not working
- Next by Date: Re: Array size depending on symbol address
- Previous by thread: Re: sizeof a union
- Next by thread: Re: sizeof a union
- Index(es):
Relevant Pages
|