I was trying a code with pointer arithmetic, but it seems to give error.
The pointer *p
to arr gives desired output with pointer arithmetic, but when i do the same with *k
, it gives an error.
#include<stdio.h>
main(){
int arr[]={1,2,3,4};
int *p=arr;
int *k={1,2,3,4};
printf("%d",*arr+2);
printf("%d",*k+2);
}
I expect that *k+2
gives exact same output as *arr+2
, but it doesn't happen that way. What's the possible reason