I'm trying to compare the element pointed by an iterator to an integer, but so far i haven't had any luck in doing so. please correct whatever i'm doing wrong. Thank you.
vector<int>::iterator y;
for (int i = 0;i<n2;i++)
{
cin>>temp;
cnt = 0;
y = lower_bound(a.begin(),a.end(),temp);
if (*y == temp) cout <<temp<<"found at"<<int(y-a.begin()+1)<<endl;
else cout<<temp<<"Not found"<<endl;
}
error msg = "vector iterator not dereferencable"