By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,792 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,792 IT Pros & Developers. It's quick & easy.

Size of structure in C without using sizeof()

P: 1
How to determine the size of a structure without using the sizeof() operator
Sep 19 '07 #1
Share this Question
Share on Google+
2 Replies

gpraghuram
Expert 100+
P: 1,275
How to determine the size of a structure without using the sizeof() operator
Use the following idea
1)Declare a structure object(stack object) locally
2)Declare another integer variable after that.
3)Get the address of both the variables and subtract the address to get the size of structure

Raghuram
Sep 19 '07 #2

ashitpro
Expert 100+
P: 542
consider following structure as example

struct abc
{
//declarations
};

take array of objects,

struct abc obj[2];

then obj[2]-obj[1] will give you the size of structure
Sep 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.