假设您有一个包含 10 个元素的 int arr[] 和一个 int * ptr。我认为以下几行会导致错误,但它会打印 0 作为存储在 ptr 中的值。它是如何计算为0的?
ptr = arr;//ptr currently points to the first element in arr
ptr = (arr + 10);//points to what would be the llth element in memory for arr
printf("ptr %p\n", ptr);//this displays where the 11th element would be in memory
printf("*ptr %i\n", *ptr);//why would this print 0?