Re: is it possible to size a pointer's target?

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

 



Erik wrote:
> Tom St Denis skrev:
>   
>> The only way a function can know the length of an array pointed to by a
>> pointer is by the caller passing that information to the function.
>>
>> Probably the best way if you want to clear up the clutter is to use a
>> struct which has both a pointer and length (maybe stored as an int).
>>   
>>     
> Length as an int?!? Sounds weird. What are negative values supposed to
> mean? It has to be an unsigned type, maybe size_t.
>   
Your head won't explode if you use an int to count something. 
Especially, since we all verify our code anyways right?

That said, size_t would probably be more appropriate, but since it was
6am and I was answering a relatively newbie question anyways, I didn't
want to confuse the matter.


Tom

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux