Whats wrong with this code? (arrays-binary search)

#include
using namespace std;

int binary_search(long long int arr[],long long int m,long long int n){

long long int s=arr[0];
long long int e=arr[n-1];
long long int *pt;
long long int *ptr;


while(s<=e){
	
	long long int mid=(s+e)/2;

	if(mid==m){
		pt=&mid;
		ptr=&arr[0];
		int ans=pt-ptr;
		return ans;
	}
	else if(mid<m){
		s=mid+1;
	}
	else{
		e=mid-1;
	}

}

return -1;

}

int main(){
long long int n;
cin>>n;

long long int arr[n];

for(int i=0;i<n;i++){
	cin>>arr[i];
}

long long int m;
cin>>m;

cout<<binary_search(arr,m,n);

}

hello @vanshit02

initialisation s=0 , e=n-1

in place of m , u should use arr[m]

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.