Greetings.
In article <3fb1f5f7@usenet01.boi.hp.com>, sahukar praveen wrote:[color=blue]
> "Jeff" <agenthunt@netcourrier.com> wrote in message
> news:6c79eab5.0311120036.7a39e994@posting.google.c om...[color=green]
>> I'm kind of new to C programming, but here's a little question.
>> Usually, when you have an array of chars, you put a \0 at the end of
>> it to terminate the string. That way, it is possible with functions
>> like strlen to get the array size. But is it possible to do the same
>> thing with an array of integers or floats? And are there any
>> functions that do so ?[/color]
>
> character array with trailing '\0' represent C strings. This is not
> applicable to integer/float arrays.[/color]
Sure it is, in the general case. Adding a particular sentinel value to
the end of an array is useful when passing arrays to functions that
don't also take the array size as an argument.
To the OP: There are no standard sentinel values for non-char arrays,
and (partly therefore) no standard functions to return the number of
assigned elements in non-char arrays. However, it's a rather simple
matter to write your own functions to do so; simply have a pointer loop
over the array until it reaches the sentinel value. Either keep a loop
counter, or return the difference between the pointer value at the end
of the loop and the pointer value at the beginning of the loop.
Regards,
Tristan
--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\
http://www.nothingisreal.com/ >< To finish what you