How are parameters of a function executed?

c

Solution

If we have a function with the following prototype:

int function(int x, int y, int z);

And we call it like so:

function( something_a(), something_b(), something_c() );

We have no ability to presume the order of execution of `something_a`, `something_b` and `something_c`.

On the other hand, we can use the comma operator as follows:

int main() {
    int x;
    something_a(), something_b();
    something_c();
}

In this case, we know that `something_a` will be called, then `something_b`, and finally `something_c`.

In summary, the comma found in a function call, is not the comma operator.

Problem

Possible Duplicate: function parameter evaluation order Assuming that I have a function with 4 arguments. Which parameter is considered first for execution and why. I was trying to understand the `,` operator's significance used for the function prototype. As is the rule is it the last variable considered first?

Original source

Related problems