Xref: utzoo comp.misc:2528 comp.lang.c:10568
Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl
From: karl@haddock.ISC.COM (Karl Heuer)
Newsgroups: comp.misc,comp.lang.c
Subject: Re: Programming style with arrays, summary
Keywords: programming style, arrays
Message-ID: <4417@haddock.ISC.COM>
Date: 6 Jun 88 15:40:59 GMT
References: <778@dick.cs.vu.nl>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Followup-To: comp.lang.c
Organization: Interactive Systems, Boston
Lines: 16

In article <778@dick.cs.vu.nl> dick@cs.vu.nl (Dick Grune) writes:
>	if (p >= &array[N]) ...
>	for (p = &array[0]; p < &array[N]; p++) ...
>both of which look sane and understandable.  I seriously thought about
>adopting these "templates" systematically in my coding, when I realized that
>for it to work, you would have to declare N as a long.  Otherwise you lose on
>machines with 2-byte ints and 4-byte pointers.

It's not the size of a pointer that matters; it's just a question of what is
the maximum size of an array.  (I.e., if you have 4-byte pointers but no array
can ever have more than 65535 elements, then a 2-byte int will suffice.)  This
has nothing to do with "&array[N]" vs. "array+N"; either both will work, or
neither.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
Followups to comp.lang.c.