I am running gcc 7.4.0 on ubuntu 18.04. I compiled and ran the following code
#include<stdio.h>
int main() {
int *p;
int a[2];
a[0] = 100;
a[1] = 200;
p = a;
int b = 10;
printf("%d\t%d", ++*p, *p);
printf("\n%d\n", *p);
printf("%d\t%d", ++b, b);
printf("\n%d\n", b);
return 0;
}
I am getting this output:
101 100
101
11 11
11
Why is the pre-increment operator behaving differently with the integer value pointed by pointer and the ordinary integer value?