A pointer array is simply an array whose elements are pointers.
For example, if we declare:
int *iptr[10];
then iptr is an array containing ten integer pointers. Each element of iptr points to an integer stored in another array.
Your task is to write a function max that returns the maximum integer among the elements pointed to by a pointer array.
The function definition is:
int max(int *iptr[], int n);
The following program shows how the max function can be used in the main function:
#include <stdio.h>
#define N 10
int max(int *iptr[], int n);
int main (void)
{
int i;
int array[N];
int *iptr[N];
for (i = 0; i < N; i++) {
scanf("%d", &(array[i]));
iptr[i] = &(array[i]);
}
printf("%d\n", max(iptr, N));
return 0;
}
The input consists of N integers (where N = 10 in this problem).
These integers are read from standard input, separated by spaces or newlines.
The program outputs the maximum value among the integers pointed to by the pointer array.