Pointer to Array of Structs

This is a discussion on Pointer to Array of Structs within the C Programming forums, part of the General Programming Boards category; Got a quick question for everyone. Let's say that I have an array of pointers that points to an array ...

  1. #1
    Unregistered
    Guest

    Pointer to Array of Structs

    Got a quick question for everyone. Let's say that I have an array of pointers that points to an array of structs. Such as:

    HashNode ** Htable; //where HashNode is a struct
    HashNode * pa;
    pa=Htable;

    Now, to access the second element in this array of HashNodes can I just increment pa using the ++ operator or do I need to use the sizeof(HashNode) to increment this to the next element in the array?

    Thanks for the Help.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    just use ++ as in

    pa++;

    the size of each element is automatically taken into account(that is if your not doing crazy stuff you probably shouldnt be).
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Sayeh
    Guest
    Are you aware that you can also say pa[x][y]...

    enjoy

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 04:36 AM
  2. pointer to multidimensional array
    By Bigbio2002 in forum C++ Programming
    Replies: 4
    Last Post: 02-05-2006, 10:29 PM
  3. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 02:34 PM
  4. accessing array of structs values
    By WaterNut in forum C++ Programming
    Replies: 12
    Last Post: 07-08-2004, 09:47 PM
  5. Replies: 41
    Last Post: 07-04-2004, 04:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21