Re: Is this correct

From: Daniel A. Koepke (dkoepke@california.com)
Date: 11/24/99


On Wed, 24 Nov 1999, Michael J. McGillick wrote:

> Hello:
>
> Am I missing something here, or does this look incorrect?  In act.item.c,
> line 1128 and 1129 show:
>
>    {"$n wears $p on $s body.",
>     "You wear $p on your body.",},
>
> Notice the extra comma in between " and } on the second line.  I looked at
> all of the other entries, and none of them are set up that way.  According
> to the way the array is defined, isn't this incorrect or am I missing
> something?

As others have said, it's just a typo.  Note that sometimes C is pretty
flexible with its syntax (which isn't necessarily a good thing).  For
instance, you can add commas like the above without causing any problem.
Or, even better (read: worse), is the fact that you can transpose the
subscript and variable.  For instance, we all know the following to be
correct,

    int array[10], i;
    for (i = 0; i < 10; i++) array[i] = 0;

But you could also write the exact same code as,

    int array[10], i;
    for (i = 0; i < 10; i++) i[array] = 0;

Weird, right?  It's due to the fact that C doesn't differentiate between
pointers and arrays.  In short this means 'array[i]' == '*(array+i)'.
And, of course, by that, we know that 'i[array]' == '*(i+array)', and we
know from elementary school that a+b == b+a.  You can even use literal
integers: i.e., '1[array] = 1;' is the same as 'array[1] = 1;'.

A fun fact, but useless unless you're trying to confuse the hell out of
everyone.

-dak


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST