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: Dirk Stoecker <stoecker@xxxxxxxxxxxxxx>, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings
From: Reinier Post <rp@xxxxxxxxxx>
Date: Thu, 25 Jan 2001 16:55:00 +0100

On Thu, Jan 25, 2001 at 08:45:01AM +0100, Dirk Stoecker wrote:

> > Try:
> >       int *b = a + 5;
> >       ...
> >       printf("b[-1]=%d\n", b[-1]);
> > 
> 
> This is required often, when doing pointer arithmetics and accessing
> fields, which have already been processd (e.g. when using *(p++)) and
> for any reason needing it again.
> 
> But I prefer to use *(p-1) instead of p[-1], as this is much better style.

I'm no better programmer than you are, but I don't think mixing pointers
and subscripts is good style at all.

-- 
Reinier



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