Task: Find Maximum in Array
You will solve this exercise starting from the find-max.c
file located in the tasks/find-max/support
directory.
Implement the following functions:
find_max(void *arr, int n, int element_size, int (*compare)(const void *, const void *))
which calculates the maximum element from an array based on a given comparison function:
compare(const void *a, const void *b)
To test the implementation, enter the tests/
directory and run:
make check
In case of a correct solution, you will get an output such as:
test_compare ........................ passed ... 30
test_find_max ........................ passed ... 70
Total: 100/100
If you’re having difficulties solving this exercise, go through this reading material.