Length of Array in C
Q: How to count length of array in C/C++?
A:
———- cut here ———-
typedef struct {
int x;
int y;
}ok ;
int main(){
ok i [] = {
{1,2},
{3,4}
};
printf(“SIZE: %d\n”,sizeof (i) / sizeof (*i));
return 0;
}
==> Size = sizeof(i)/sizeof(*i)
Thanks for this tip.
shashi
January 3, 2009 at 12:46 am