Ben Bacarisse
7/11/2008 11:23:00 PM
Keith Thompson <kst-u@mib.org> writes:
> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> In fact, an array can hold more than one string, but exactly how many
>> is a matter of definition. This array:
>>
>> char my_strings[] = { 'a', 'b', 'c', '\0', 'd', '\0' };
>>
>> has at least two strings in it: the C expressions my_strings and
>> my_strings + 4 both point to the start of valid strings
>
> Yes, since 6 is at least two. (I see that you addressed this
> below.)
I knew I'd have to!
>> (some people
>> choose to say that my_strings *is* a string -- feel free to do that in
>> casual conversation, but technically it is a pointer to the start of a
>> string).
>
> Yes and no. ``my_strings'' is the name of an object. That object is
> an array object, not a pointer object. On the other hand, if the name
> ``my_object'' is used as an expression, it will usually be implicitly
> converted to a pointer value (a char* pointing to the 'a'). On the
> other other hand, this conversion doesn't happen if ``my_object'' is
> the operand of a unary "&" or "sizeof" operator.
>
> So whether "my_object is a pointer" depends on whether you mean the
> object named "my_object" or the expression my_object.
Yes. I did say "the expressions my_strings and my_strings + 4" but
obviously I should have repeated "the expression" in the parenthetical
remark to avoid ambiguity. I'll get the hang of c.l.c eventually.
--
Ben.