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. &foo[bar] or (foo + bar) ?

&foo[bar] or (foo + bar) ?

Scheduled Pinned Locked Moved C / C++ / MFC
designquestioncsscomgraphics
22 Posts 9 Posters 104 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.
  • honey the codewitchH honey the codewitch

    That's not really a trick. It's "get me the address of the Nth array element." It's just another way of writing (foo + bar); If you insist on not mixing pointer and array ops than you'd be stuck with the very syntax you don't like in order to get the address of an array element, unless there's a 3rd way to do it I'm not considering?

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    J Offline
    J Offline
    jschell
    wrote on last edited by
    #21

    honey the codewitch wrote:

    It's just another way of writing (foo + bar);

    yes I know.

    honey the codewitch wrote:

    If you insist on not mixing pointer and array ops

    Not sure what you mean. If I create an array of pointers then I would use it like an array. If I create a pointer to memory that contains sequential blocks (regardless of type) then I would use it like a pointer. The fact that syntactically the access is the same and tradable is not a consideration.

    honey the codewitchH 1 Reply Last reply
    0
    • J jschell

      honey the codewitch wrote:

      It's just another way of writing (foo + bar);

      yes I know.

      honey the codewitch wrote:

      If you insist on not mixing pointer and array ops

      Not sure what you mean. If I create an array of pointers then I would use it like an array. If I create a pointer to memory that contains sequential blocks (regardless of type) then I would use it like a pointer. The fact that syntactically the access is the same and tradable is not a consideration.

      honey the codewitchH Offline
      honey the codewitchH Offline
      honey the codewitch
      wrote on last edited by
      #22

      jschell wrote:

      Not sure what you mean.

      I mean this

      jschell wrote:

      If I create an array of pointers then I would use it like an array. If I create a pointer to memory that contains sequential blocks (regardless of type) then I would use it like a pointer

      So I think somewhere we started talking past each other.

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      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