Function parameter evaluation order is unspecified in C/C++. Parameters might be read from right to left or left to right. Throw a dice and check your answer. My previous assumption was that function parameters are read from right to left. For this assumption, answer would have been x = 22, x++ = 21 and ++x = 21. But o/p i got is x =22, x++ = 21 and ++x = 22 which is a (headbang) o/p. Please refer to the following link and let me know if you understood it completely.
Function parameter evaluation order is unspecified in C/C++. Parameters might be read from right to left or left to right. Throw a dice and check your answer.
ReplyDeleteMy previous assumption was that function parameters are read from right to left. For this assumption, answer would have been x = 22, x++ = 21 and ++x = 21. But o/p i got is x =22, x++ = 21 and ++x = 22 which is a (headbang) o/p.
Please refer to the following link and let me know if you understood it completely.
http://stackoverflow.com/questions/376278/parameter-evaluation-order-before-a-function-calling-in-c