Function call evaluation order




Hi folks,

I need help to explain the behavior with the code below. I would like to
chain up function call into a single line, while the order of the function
call is correct, I cannot be certain with order the expression within the
function call is evaluated.

Woud it be better, then, to write all the function call into seperate lines?

With regards,
Cheng Wu


Code:

#include <stdio.h>
#include <string>

using namespace std;

void main()
{
char* data[] = {" zero ", " one ", " two ", " three "};
string s;
int i;

i = 0;
s.assign(data[i++]).append(data[i++]).append(data[i++]);
printf("%s\n", s.c_str());

i = 0;
s.assign(data[++i]).append(data[++i]).append(data[++i]);
printf("%s\n", s.c_str());

i = 0;
s.assign(data[i++]);
s.append(data[i++]);
s.append(data[i++]);
printf("%s\n", s.c_str());
}


Output:

zero zero zero
three three three
zero one two


.