Precedence question

This is a discussion on Precedence question within the C++ Programming forums, part of the General Programming Boards category; What does *++x mean when x is a pointer to an int? Are *(x++) and *(++x) the same?...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    65

    Precedence question

    What does *++x mean when x is a pointer to an int?
    Are *(x++) and *(++x) the same?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    *(x++) will increment x (make it point to the next integer in line) after dereferencing, while *(++x) will increment x before.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    65
    So the parentheses don't do anything?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You mean between *(x++) and *x++? Those are the same. The parentheses are redundant in *++x, since there's no way to interpret that other than pre-increment x, then dereference.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    65
    I mean between *(x++) and *(++x).

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,459
    Quote Originally Posted by jw232 View Post
    I mean between *(x++) and *(++x).
    Difference here is not in parentheses. So what is the actual question?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,288
    Quote Originally Posted by jw232 View Post
    I mean between *(x++) and *(++x).
    Tabstop answered that in his first post.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 12:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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