Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > sizeof a relati...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 1065 of 1126
Post > Topic >>

sizeof a relative pointer in a struct

by ManicQin <ManicQin@[EMAIL PROTECTED] > Mar 20, 2008 at 01:09 AM

Hi all.
I'm trying to get the size of a variable in a struct by his relative
postion i.e.

///
#define offsetof(s,m)   (size_t)&(((s *)0)->m)

struct ThePimp{
char rings[10];
char blings[20];
};

int sizeOfBling = sizeof( (*char)&ThePimp +
(char)offsetof(ThePimp,blings) );

///
(If I have any syntax mistakes please ignore)

You can easily predict that sizeOfBling will be 4... (sizeof(int*))
Is there any way to acomplish it?

Thanks
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 4 Posts in Topic:
sizeof a relative pointer in a struct
ManicQin <ManicQin@[EM  2008-03-20 01:09:38 
Re: sizeof a relative pointer in a struct
Kenneth Brody <kenbrod  2008-03-20 15:57:21 
Re: sizeof a relative pointer in a struct
Martin Ambuhl <mambuhl  2008-03-20 15:57:16 
Re: sizeof a relative pointer in a struct
Carl Barron <cbarron41  2008-03-22 12:23:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 0:44:59 CDT 2008.