Write a function to print the elements in an array using pointers, but without using subscripts!
Hints:
- Pointers can be compared. In particular p < p + 1 is always true!
- What address is in a + n?
- The initial value of p is the address of the first element of the array. How do you make p point to the next element of the array? How do you know when p is pointing to a location beyond the last element of the array? How do you print the integer p is pointing to?
void printArray(int *a, int n) { int *p = a; }