Re: sizeof and passing pointer
On Sun, 21 Oct 2007 18:36:09 +0100, Malcolm McLean wrote:
> "jason" <jisis@notmal.com> wrote in message
>> Hello,
>>
>> I'm a beginning C programmer and I have a question regarding arrays and
>> finding the number of entries present within an array.
>>
> Arrays decay to pointers when you pass them to functions. So you need to
> pass in the number of elements as a separate parameter.
>
> When you start writing real programs you will find that the number of
> cases where you know an array's size at compile time is quite few.
> Usually the size is determined by the data the user inputs, so you must
> allocate the space with malloc().
Ok thankx for that !
But just to make sure; what does `decay' exactly mean in this case ? And
what properties of the pointer, when passed to a function actually
change ?
Thank you.
Jason.
|