|
-
July 8th, 2005, 08:00 AM
#1
Our Own code for Sizeof() operator
Hi all,
I tried for this and I am unable to get an idea, how to write my own code for sizeof.
My english is poor. pls understand.For to understand i am writing an example below:
main()
{
int i;
printf("size of integer is = %d",sizeof(i));
}
output:
size of integer is = 2
Now, here i want write my own function for to calute size of integer.
Thank u..
-
August 27th, 2009, 11:54 AM
#2
Re: Our Own code for Sizeof() operator
how about this macro from another forum
i havent tried this out yet
#define mySizeof(x){__typeof__(x) tmp ;(char*)(&tmp + 1) - (char*)(&tmp);}
e.g
mySizeof(int)
int a;
mySizeof(a);
-
August 27th, 2009, 02:25 PM
#3
Re: Our Own code for Sizeof() operator
Welcome to the forums, swtsvn. 
Please remember to keep your posts relevant. This thread is over 4 years old!
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|