int i;
for ( i = 0; i < size; ++i )
if ( arr[i] == val )
return i;
return -1;
}
#define ARRSIZE 50
#define TOFIND 50
int main(void){
int arr[ARRSIZE], i;
for ( i = 0; i < ARRSIZE; ++i )
arr[i] = i + 1;
i = valIndex(arr, ARRSIZE, TOFIND);
if ( i >= 0 )
printf("Index of value %d is %d\n", TOFIND, i);
else
printf("Value %d not found in array.\n", TOFIND);
return 0;
}