Passing an array to a function, failed with exit code 1 (Xcode)
Hello people,
I'm writing a program (on Xcode, OSX) to find the largest number in an array by passing it to a function. Apparently, the compiler reports no other error except 'failed with exit code 1'. I'm stuck.
Code:
#include <stdio.h>
int largest(int array[5],int holder);
int main()
{
int array[5],counter,temp;
printf("Enter five numbers to select the largest of them:\n");
for(counter=0;counter<5;counter++)
{
scanf("%d",&array[counter]);
}
temp=largest(array,5);
printf("%d\n",temp);
}
int largest(int array[], int holder)
{
int counter,large;
large=array[0];
for(counter=0;counter<5;counter++)
{
if(large<array[counter])
large=array[counter];
}
return(large);
}
Can any one suggest what is wrong in the program? A help would be appreciated :)