mdh <mdeh@[EMAIL PROTECTED]
> writes:
> On May 5, 4:23 pm, Keith Thompson <ks...@[EMAIL PROTECTED]
> wrote:
> >....... Any such expression will be converted to a
>> pointer, and the called function has absolutely no way of knowing
>> whether such a conversion has happened. ....
>
> Thanks Keith...that's what I thought, but just wanted to be sure.
> In C, is it quite common to pass a pointer to which one has allocated
> an array, as K&R do in this example?
Yes, it's extremely common; it's how arrays are usually dealt with in
C.
You also usually need some way to specify how big the array is, or how
big the ****tion you're interested in is. For strings, this is
generally determined by the position of the '\0' terminator. For
other arrays, it's common to pass a second argument that specifies the
length of the array (see, for example, the third parameter of
memcpy()).
--
Keith Thompson (The_Other_Keith) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


|