*p++ in general adds 1 to pointer then references. But printf is taking the value after just dereferencing while the pointer got increased then dereferenced.
#include<stdio.h>
int main()
{
int a[] = { 10,20,30 };
int *p = a;
printf("%d\n", *p++);//this makes p point at 20 but prints 10
printf("%d\n", *p);//prints 20
printf("%d\n", a[0]);//prints 10
}
Can someone please explain why this is happening ?
Thanks in advance