0

I have this piece of code:

int get()
{
    static int i = 1;
    return i++;
}

int main(int argc, char *argv[])
{
    printf("%d %d %d\n", get(), get(), get());
    return 0;
}

And I thought the output would give me 1 2 3 but instead it returns 3 2 1. So my question is, how does the order of evaluation compute this? I read that it depends on the compiler so it can be either of the above but I am not so sure about the answer.

jimmyhuang0904
  • 181
  • 3
  • 10

0 Answers0