Fill This Form To Receive Instant Help
Homework answers / question archive / Let us say that ip is a pointer pointing to an item in an integer array
Let us say that ip is a pointer pointing to an item in an integer array. Which of the following expressions point to the valid items within the array? ip[-2] or ip[2]? Why?
The index of an array must be non-negative integer. So:
ip[-2] is invalid since the index cannot be negative number;
ip[2] is valid if the length of the array is greater than or equal to 3;
ip[2] is invalid too if the length of the array is less than 3, index 2 will overflow.