Thank you very much for the response, cas. I tried to change my code (wrote int **, instead of int *, changed to *h in functions). However, it doesn't compile me.
What am i doing wrong now?
Code:
#include <stdio.h>#include <stdlib.h>
void ArrayScan(int n, int **h);
void ArrayMaximum(int n, int *h, int x);
int main()
{
int n, *array;
int max = 0;
printf("Write the number of random numbers: ");
scanf("%d", &n);
ArrayScan(n,&array);
ArrayMaximum(n,array, max);
free(array);
getch();
}
void ArrayScan(int n, int **h)
{
int i = 0;
h = (int*)malloc(n* sizeof(int));
for ( ; i<n; i++)
scanf("%d", *(h+i));
}
void ArrayMaximum(int n, int *h, int x)
{
int i=0;
x = *(h+i);
for( ;i<n;i++)
{
if (*(h+i)>x)
x = *(h+i);
};
printf("The maximum is: %d", x);
}