2
#include <stdio.h>

print(int* a,int* b,int* c,int* d,int* e)
{
    printf("\n%d %d %d %d %d\n",*a,*b,*c,*d,*e);
}

main()
{
    static int arr[]={97,98,99,100,101,102,103,104};
    int *ptr=arr+1;
    print(++ptr,ptr--,ptr,ptr++,++ptr);
}

Output:

100 100 100 99 100

I am a little confused with the output. Is it because of the undefined evaluation order of function or there is something else that I am missing?

Adam Stelmaszczyk
  • 19,665
  • 4
  • 70
  • 110
user2492165
  • 93
  • 1
  • 6
  • When you hit UB, anything goes? – Dennis Meng Aug 23 '13 at 16:25
  • Duplicate http://stackoverflow.com/questions/376278/parameter-evaluation-order-before-a-function-calling-in-c – Phlucious Aug 23 '13 at 16:30
  • There is no "undefined evaluation order of function" there. There is, however, an undefined order of evaluation of the expressions that become the arguments passed to the function... – twalberg Aug 23 '13 at 17:05

0 Answers0