pointer value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JD

    #1

    pointer value

    int (*a)[10];
    a++;
    what will be the value of a?

  • Michael Mair

    #2
    Re: pointer value

    JD wrote:[color=blue]
    > int (*a)[10];
    > a++;
    > what will be the value of a?[/color]

    As always with ++ on a pointer:
    (unsigned char *)a + 1*sizeof *a

    As a points to array 10 of int, sizeof *a == 10 * sizeof (int).

    As you have not initialised the pointer, the behaviour is
    undefined.

    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.

    Comment

    • Emmanuel Delahaye

      #3
      Re: pointer value

      JD wrote on 30/07/05 :[color=blue]
      > int (*a)[10];
      > a++;
      > what will be the value of a?[/color]

      a + 1

      --
      Emmanuel
      The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
      The C-library: http://www.dinkumware.com/refxc.html

      "Clearly your code does not meet the original spec."
      "You are sentenced to 30 lashes with a wet noodle."
      -- Jerry Coffin in a.l.c.c++


      Comment

      Working...