Showing posts with label sizeof. Show all posts
Showing posts with label sizeof. Show all posts

Feb 5, 2009

how to determine the size of the array?

how to determine the size of the array?
{{{
int a[10];
sizeof(a)/sizeof(int);
}}}

Jan 18, 2009

How to implement sizeof

How to implement sizeof
#define sizeof(var) (int)(&var+1)-(int)&var

#define SIZE1(type) (size_t)((type *)100 + 1) - (size_t)((type *)100)


Int a[2]
Cout<<&a[1]-&a[0]<< endl;//1
Cout<<(int)&a[1]-(int)&a[0]<< endl;//4