I'm new to C programming and trying to understand how pointer arithmetic works. The below printf statement prints 2 when the arguments for printf is *(p+2) and 4 with for *p. Could you please explain this behaviour ?
#include <stdio.h>
#include <conio.h>
int main()
{
int arr[4] = {4,3,2,1}, *p = arr;
printf("
%d", *(p+2));
return 0;
}
See Question&Answers more detail:os