Ady Wicaksono Daily Activities

Length of Array in C

with one comment

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)

Written by adywicaksono

July 14, 2007 at 11:51 am

Posted in Programming

One Response

Subscribe to comments with RSS.

  1. Thanks for this tip.

    shashi

    January 3, 2009 at 12:46 am


Leave a Reply