M
Micah Cowan
Mark McIntyre said:Mark McIntyre said:On Sun, 12 Oct 2003 06:55:35 +0200, in comp.lang.c , "Alex Vinokur"
double foo[] = {1.0, 2.0, 3.0, 4.0, 5.0};
/* Could you print here how many elements the foo array contains? */
Yes, because I can count. Evidently elementary numeracy is a dying art
I suspect he wanted to know how to obtain and print out the size
of array foo???
Yes, but in general, or in the highly specific case of
T foo[] = {someinitialisers};
?
I'm trying (badly) to point out that C offers no way to reliably
determine the size of an array in nontrivial code, other than
remembering it. The sizeof method is merely a way of remembering it,
IMHO.
The difference is, its the C implementation's responsibility to
remember it in this case, not yours. And regardless of whether
it's "merely a way fo remembering it" or not, it will clearly
give you the number of elements in foo for
T foo[] = {someinitialisers};
So what's the problem?
-Micah