++*f = ++*g; What will happen in the above code?
Anonymous
Dearest Ludwig, Um... No. Did you actually get this compile error or are you speculating? Here is a real answer: Prefix and dereference operations have the same precedence and associate right-to-left. So, the contents of "g" are incremented before being set to the value of "f" which are also incremented. If we are talking ints, say *f=2 and *g=4, then dereference happens, values are incremented, then the incremented value of *g is assigned to *f. The prefix on the left hand side is overwritten by the assignment and *f=*g=5.
Check out your Company Bowl for anonymous work chats.