I am trying to search an array that the user inputs to determine the largest number entered. The Array is entered no problem, but I am having problems with my search.
What I have is a table format array, and I think my logic for the search will not work on a table. I am trying to use pointers for my search. perhaps it is not the easiest way, but since I am currently learning arrays and pointers I figured by using them it was the best way to actually learn them. Can anyone advise me as to what I might do to correct this? The code below is the function I am calling from the main.
Code:
int Table (void)
{
int array[4][4] = {0};
int row;
int col;
int *large;
int *end;
int *mover;
printf("Enter 4 sets of 4 integers, for a total of 16 numbers\n");
printf("Please use the following format: nnn nnn nnn nnn <enter>.\n");
/* Enter Data into Table */
for (row = 0; row < 4; row++)
{
printf("\nEnter one set of numbers: ");
for (col = 0; col < 4; col++)
{
scanf("%d", &array[row][col]);
}
}
/*Find and print largest number in the array entered*/
end= array [4][4];
for (large = array, mover= array +1; mover<= end; mover++)
if (*mover> *large)
end= mover;
printf("The biggest number was: %d\n", *large);
return 0;
}
As always any help, advise and guidance is greatly appreciated.
Thanks,
DD