Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2001:
[Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings
Home

[Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings
From: Gaute B Strokkenes <gs234@xxxxxxxxxxxxxxxx>
Date: 25 Jan 2001 17:32:57 +0000

On Wed, 24 Jan 2001, dwpfitzner@xxxxxxxxx wrote:

> Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: >
> 
>> [ Negative subscript values? Is this a gnu extension? What are the
>> semantics? 
> 
> Negative subscript values have just the same semantics as
> non-negative ones -- its just pointer arithmetic:
>    a[b]  =  *(a + b)

Incidentally, this means that [] is abelian:

int
main (int argc, char *argv[])
{
  printf("The third letter of the alphabet is %c.\n", 2["ABC"]);
}

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
Impudent..  Yet possessing a certain ALUMINUM SILICATE
 overbite....Needs REDDY-WHIP!!



[Prev in Thread] Current Thread [Next in Thread]