Dzień dobry. Napisałem prosty program szukający największej liczby w zbiorze. Próbowałem go przerobić aby main wywoływał tą funkcję ale wyskakuje mi błąd
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<math.h>
#include <stdlib.h>
int NwZ(int* x, int l);
int main()
{
int n;
printf("Podaj liczebnosc zbioru:\t");
scanf("%i", &n);
if (n <= 0)
{
printf("blad");
return 0;
}
int* a = (int*)malloc(sizeof(int) * (n + 1));
int i = 1;
while (i <= n)
{
printf("Podaj %i liczbe\t", i);
scanf("%i", &a[i]);
i = i + 1;
}
NwZ(a,n);
}
int NwZ(int* x, int l)
{
int max = x[1];
int i = 2;
while (i <= l)
{
if (x[i] > max)
{
max = x[i];
}
i = i + 1;
}
printf("%i", max);
}
i nie wiem co źle zrobiłem.