i was practicing pointers and i saw that when i define a pointer and assign an array to that pointer, i was able to get the value in a specific index when i use the pointer name with that index instead of array name, like,
int arr[5] = {1,2,3,4,5};
int *ptr;
ptr = arr;
printf("%d", ptr[1]); // prints out 2
I was expecting to see the value when i use *ptr[1] and the specific index adress when i use ptr[1], but when i use *ptr[1] i get compiler error. I thought pointer name keeps the adress and using the name with * gives the value in that adress.
Am i missing something here ? Why pointer with array works that way ?