precedence

This is a discussion on precedence within the C Programming forums, part of the General Programming Boards category; if the postfix operaters ++ and -- have higher precedence than the = sign how come *a++ = *b++; will ...

  1. #1
    Unregistered
    Guest

    precedence

    if the postfix operaters ++ and -- have higher precedence than the = sign how come
    *a++ = *b++;

    will asign b to a, and then inc. the pointers?

  2. #2
    Registered User dharh's Avatar
    Join Date
    Jan 2002
    Posts
    51
    Because the aforementioned ++ and -- are after the variable, if you had done:

    *(++a) = *(++b);

    it would be different.

  3. #3
    Unregistered
    Guest
    Well… the parenthesis aren’t necessary.

    *(++a) = *(++b) is the same as *++a = *++b;

    but

    *(a++) = *(b++) is not the same as *a++ *b++;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C4554 Warning, check operator precedence for possible error
    By Bassquake in forum C++ Programming
    Replies: 2
    Last Post: 06-05-2008, 06:13 AM
  2. Replies: 15
    Last Post: 11-04-2006, 04:06 AM
  3. precedence / associativity
    By anthonye in forum C++ Programming
    Replies: 1
    Last Post: 11-06-2003, 11:03 AM
  4. Less than or equal - precedence in for loops
    By Idle in forum C Programming
    Replies: 4
    Last Post: 06-23-2003, 07:19 PM
  5. precedence
    By modec in forum C Programming
    Replies: 3
    Last Post: 05-22-2003, 12:37 PM

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