how to determine the size of the array?
{{{
int a[10];
sizeof(a)/sizeof(int);
}}}
Showing posts with label sizeof. Show all posts
Showing posts with label sizeof. Show all posts
Feb 5, 2009
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
#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
Subscribe to:
Posts (Atom)