I don't know what I'm doing wrong I'm stuck on this for the past two hours. Any help would be highly appreciated.
My code is the following:-
#include <stdio.h>
int* findLargest(int* arr,int size){
return &arr[size-1];
}
int main(){
int size=3;
int arr[3]={3,4,5};
int* largest=&arr[size-1];
int* largest2=malloc(100);
largest2=findLargest(*arr,size);
printf("%d",largest);
printf("%d",*largest2);
}
I get a garbage value when I execute.
findlargest.c:16:26: warning: passing argument 1 of ‘findLargest’ makes pointer from integer without a cast