I'm trying to use recursion to find the minimum integer in an array.
This is my code:
int minArray(int* array, int size){
if (size == 0){
return array[0];
}
int min = array[0];
if (min > minArray(array+1,size-1)){
min = minArray(array+1,size-1);
}
return min;
}
What is wrong with it? If i call the function on {1,2,3,4,5}, it will return 0.