I wrote an example that hopefully explains what you are trying to do. There is a template function in <algorithm> std::find that you could use in the same way as you would call this function.
#include <iostream>
int* find(int* first, int* last, int val)
{
while(first != last)
{
if(*first == val) //dereference pointer, is it the same as val?
return first; //found the element so return a pointer to it
++first; //make 'first' point to the next element
}
return last; //val wasn't found
}
int main()
{
int a[] = {1, 2, 3, 4, 5}; //array of 5 elements
int* last = a + 5; //a+5 is one past the last element in a[]
int* p = find(a, last, 3); //find the value 3 in a[]
//if p is equal to one past the last element in a[], the element wasn't found
if(p != last)
std::cout << "found: " << *p << '\n';
else
std::cout << "not found\n";
}