Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #76908

Re: just a curiosity about starting array indexing at 0 as opposed to 1

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: just a curiosity about starting array indexing at 0 as opposed to 1
Date Sun, 22 Nov 2015 12:36:56 -0800
Organization None to speak of
Lines 30
Message-ID <lnmvu54vpz.fsf@kst-u.example.com> (permalink)
References <2df732fe-b6ed-47a2-b61d-30d45a7cab91@googlegroups.com> <v9d4y.153669$fC2.133336@fx03.iad> <n2slak$45o$1@speranza.aioe.org> <n2snk9$khg$1@dont-email.me> <array-offset-20151122164910@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="26272"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gN0kJ0r5Rkg9MsiSwpq3y"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:iMmzDwsyztQE1cfwExU2uOBIdhw= sha1:+OxbhNUrCEnzpeY7jkR/I+Xltks=
Xref csiph.com comp.lang.c:76908

Show key headers only | View raw


ram@zedat.fu-berlin.de (Stefan Ram) writes:
> BartC <bc@freeuk.com> writes:
>>Clearly C is not going to make it easy to add any other lower bound than 
>>zero!
>
>   The following code is /not/ standard-conformant C,
>   but it might have the intended effect under some
>   implementations:
>
> #include <stdio.h>
>
> int main( void )
> { int zero_based[] ={ 1, 2, 3 };
>   int * const one_based = zero_based - 1;
>   printf
>   ( "{ %d, %d, %d }\n", 
>     one_based[ 1 ], one_based[ 2 ], one_based[ 3 ]); }
>
>   There are some automatic translation tools that transform
>   from Pascal to C, which have to deal with this problem, IIRC.
>   Once, one such a tool was used to compile TeX with a C compiler. 

I think the C version of "Numerical Recipes" (originally written
using Fortran) used that trick.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

just a curiosity about starting array indexing at 0 as opposed to 1 G G <gdotone@gmail.com> - 2015-11-21 18:50 -0800
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 supercat@casperkitty.com - 2015-11-21 19:31 -0800
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-22 00:15 -0800
      Re: just a curiosity about starting array indexing at 0 as opposed to 1 supercat@casperkitty.com - 2015-11-22 07:20 -0800
        Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-22 16:22 +0000
          Re: just a curiosity about starting array indexing at 0 as opposed to 1 supercat@casperkitty.com - 2015-11-22 08:44 -0800
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-22 10:37 -0500
      Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-22 15:50 +0000
        Re: just a curiosity about starting array indexing at 0 as opposed to 1 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-22 11:02 -0500
          Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-22 16:15 +0000
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 Ian Collins <ian-news@hotmail.com> - 2015-11-22 16:42 +1300
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 G G <gdotone@gmail.com> - 2015-11-21 19:55 -0800
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 Keith Thompson <kst-u@mib.org> - 2015-11-23 11:01 -0800
      Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-23 19:18 +0000
        Re: just a curiosity about starting array indexing at 0 as opposed to 1 Keith Thompson <kst-u@mib.org> - 2015-11-23 11:26 -0800
          Re: just a curiosity about starting array indexing at 0 as opposed to 1 glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-23 22:54 +0000
            Re: just a curiosity about starting array indexing at 0 as opposed to 1 Robert Wessel <robertwessel2@yahoo.com> - 2015-11-23 18:37 -0600
              Re: just a curiosity about starting array indexing at 0 as opposed to 1 raltbos@xs4all.nl (Richard Bos) - 2015-11-24 15:22 +0000
      Re: just a curiosity about starting array indexing at 0 as opposed to 1 raltbos@xs4all.nl (Richard Bos) - 2015-11-24 15:13 +0000
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-22 01:21 -0500
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-22 15:00 +0000
      Re: just a curiosity about starting array indexing at 0 as opposed to 1 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-22 10:15 -0500
        Re: just a curiosity about starting array indexing at 0 as opposed to 1 glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-23 13:47 +0000
          Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-23 14:50 +0000
            Re: just a curiosity about starting array indexing at 0 as opposed to 1 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-23 12:01 -0500
              Re: just a curiosity about starting array indexing at 0 as opposed to 1 James Kuyper <jameskuyper@verizon.net> - 2015-11-23 12:12 -0500
                Re: just a curiosity about starting array indexing at 0 as opposed to 1 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-23 12:57 -0500
            Re: just a curiosity about starting array indexing at 0 as opposed to 1 glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-23 23:08 +0000
          Re: just a curiosity about starting array indexing at 0 as opposed to 1 bert <bert.hutchings@btinternet.com> - 2015-11-23 08:52 -0800
      Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-22 15:42 +0000
        Re: just a curiosity about starting array indexing at 0 as opposed to 1 Keith Thompson <kst-u@mib.org> - 2015-11-22 12:36 -0800
        Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-22 21:06 +0000
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-22 10:28 +0000
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-22 12:04 +0000
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-11-22 11:24 +0000
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 G G <gdotone@gmail.com> - 2015-11-22 04:29 -0800
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 see.my.homepage@gmail.com - 2015-11-22 04:54 -0800
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 BartC <bc@freeuk.com> - 2015-11-22 13:43 +0000
    Re: just a curiosity about starting array indexing at 0 as opposed to 1 James Kuyper <jameskuyper@verizon.net> - 2015-11-22 11:04 -0500
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 Jens Stuckelberger <Jens_Stuckelberger@nowhere.net> - 2015-11-22 15:29 +0000
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-22 14:06 -0800
  Re: just a curiosity about starting array indexing at 0 as opposed to 1 John Bode <jfbode1029@gmail.com> - 2015-11-23 07:49 -0800

csiph-web