If you wonder why your code do not compile and you get a message like "All path must return a value".
It is because your code is missing a 'return'.
int searchInsert(int* nums, int numsSize, int target){
int l=0;
int h=numsSize-1;
int mid=(l+h)/2;
while(l<h)
{
if(target==nums[mid])
{
return nums[i];
}
else
if(target<nums[mid])
{
h=mid-1;
mid=(l+h)/2;
}
else
{
l=mid+1;
mid=(l+h)/2;
}
}
return h;
}