Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Array

Array

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nikesh Jagtap
    wrote on last edited by
    #1

    Why array starts with zero? Best wishes Nikesh

    CPalliniC S M C 4 Replies Last reply
    0
    • N Nikesh Jagtap

      Why array starts with zero? Best wishes Nikesh

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Because it's natural. -- the C developer ...Or [^]. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • N Nikesh Jagtap

        Why array starts with zero? Best wishes Nikesh

        S Offline
        S Offline
        Sakhalean
        wrote on last edited by
        #3

        Because 0 is the starting number

        1 Reply Last reply
        0
        • N Nikesh Jagtap

          Why array starts with zero? Best wishes Nikesh

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          (probably not the best technical explanation, but...) because the first element is at a zero "offset" from the start of the array.

          Watched code never compiles.

          L 1 Reply Last reply
          0
          • M Maximilien

            (probably not the best technical explanation, but...) because the first element is at a zero "offset" from the start of the array.

            Watched code never compiles.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Maximilien wrote:

            probably not the best technical explanation

            But may well be the clearest :thumbsup:

            It's time for a new signature.

            M 1 Reply Last reply
            0
            • L Lost User

              Maximilien wrote:

              probably not the best technical explanation

              But may well be the clearest :thumbsup:

              It's time for a new signature.

              M Offline
              M Offline
              Maximilien
              wrote on last edited by
              #6

              :-O

              Watched code never compiles.

              1 Reply Last reply
              0
              • N Nikesh Jagtap

                Why array starts with zero? Best wishes Nikesh

                C Offline
                C Offline
                Chris Losinger
                wrote on last edited by
                #7

                it makes switching between (pointer + offset) and pointer[offset] simple. if arrays started with 1, pointer[1] would be the same as pointer + 0, and C programs would be full of off-by-one errors as programmers forgot to account for the difference when switching between array notation and pointer + offset notation.

                image processing toolkits | batch image processing

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups