Re: How to increment array of pointers to strings



On Aug 5, 11:39 pm, Eric Sosman <esos...@xxxxxxxxxxxxxxxxxxxx> wrote:
On 8/5/2010 11:02 PM, Shao Miller wrote:

On Aug 5, 8:53 pm, barncat<thebarn...@xxxxxxxxx>  wrote:
Thanks All!  My brain hurts after reading and tyring to understand
your explanations. I think i get this now, or at least my program
works now :)  Thanks again
Something else to make your brain hurt: An array has elements of a
fixed size. :)  So you cannot have an array of strings of different
length.[...]

     Actually, you can.  Keeping in mind the definitions of "string"
and "string length,"

        char array[][6] = { "forty", "two" };
        assert (strlen(array[0]) != strlen(array[1]));  // woops!
        assert (sizeof(array[0]) == sizeof(array[1]));  // granted ...
Thanks, Eric. :) Let's change it to:

"Something else to make your brain hurt: An array has elements of a
fixed size. :) So you cannot have an array of arrays of 'char' with a
different number of elements for each sub-array."

Of course, one could argue that your array above is _more_ than an
array of strings, due to the padding after the second element. ;)
That is to say, if just one of the strings is long and the others
shorter, the entire array will have lots of padding, so one should be
aware of that.
.