[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] That was productive...



> From: Philip Newton [mailto:philip.newton@datenrevision.de]
> Sent: Tuesday, January 18, 2000 06:15
> To: Fun With Perl
> Subject: Re: [FWP] That was productive...

...

> This might be different if you're coming from C and used to using
sizeof()
> or strlen()... then you're working with sizes. But then C has no way
of
> telling you the index of the last element of an array.

Of course it does.  Quite unlike Perl, the type of an array in C
includes its size, which is statically compiled.

So to find the number of elements in the array a,

    sizeof(a) / sizeof(a[0])

And the index of the last element is one less than that.

--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
>



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe