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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: