Can it be assumed a evaluation order of the function parameters when calling it in C ? According to the following program, it seems that there is not a particular order when I executed it.
#include <stdio.h> int main() { int a[] = {1, 2, 3}; int * pa; pa = &a[0]; printf('a[0] = %d\ta[1] = %d\ta[2] = %d\n',*(pa), *(pa++),*(++pa)); /* Result: a[0] = 3 a[1] = 2 a[2] = 2 */ pa = &a[0]; printf('a[0] = %d\ta[1] = %d\ta[2] = %d\n',*(pa++),*(pa),*(++pa)); /* Result: a[0] = 2 a[1] = 2 a[2] = 2 */ pa = &a[0]; printf('a[0] = %d\ta[1] = %d\ta[2] = %d\n',*(pa++),*(++pa), *(pa)); /* a[0] = 2 a[1] = 2 a[2] = 1 */ }
No, function parameters are not evaluated in a defined order in C.
See Martin York’s answers to What are all the common undefined behaviour that c++ programmer should know about?.