#include<stdio.h>
int main()
{
int x=3;
int const *ptr =&x;
printf("%d",++x);
printf("\n %d",++*ptr);
return 0;
}
I am unable to get that when x is a variable not a constant then how come the error is that the since ptr is a pointer to a constant hence we cannot change its value, although ++x works fine, whats the logic behind this ?