0

Operations C

in a function whats the diferrence between ++x or x++.

29th Jan 2017, 8:08 PM
Jorge Rebelo
Jorge Rebelo - avatar
1 Resposta
+ 1
++x first increases x by 1 and then gives back x. x++ first gives back x and then increases it by 1. int x = 5; int y = ++x; /* ++x -> x is now 6, so y is also 6 */ x = 5; y = x++; /* x is 6 again, but y is now 5 */
29th Jan 2017, 8:17 PM
Robobrine
Robobrine - avatar