I couldn't figure out the reason for the output I got:-
int ar[5] = {1, 3, 5, 7, 9};
int *p = ar;
printf("%d\t%d\n", *p, *(p++));
output: 3 1
but i expected : 1 3 as p points to the 1st element and p++ points to the 2nd element.
I couldn't figure out the reason for the output I got:-
int ar[5] = {1, 3, 5, 7, 9};
int *p = ar;
printf("%d\t%d\n", *p, *(p++));
output: 3 1
but i expected : 1 3 as p points to the 1st element and p++ points to the 2nd element.
Order of evaluation for function arguments is unspecified.
order of evaluation from right to left evaluate *(p++) first and increase the address then evaluate *p which now point to next element.Try *(p+1) instead of it.
This gives a nice example how order of evaluation for function arguments is not granted.