Linear search

This is a discussion on Linear search within the C++ Programming forums, part of the General Programming Boards category; hi guyz, i am working on this c++ assignment:
1. Linear Search
I made this function and it goes through ...

Linear search

I made this function and it goes through a list of int values but i want to modify it so that it goes through all the names and returns the name found. Plz help me out guyz

Code:

int searchList(int list[], int numElems, int value)
{
int index = 0; // Used as a subscript to search array
int position = -1; // To record position of search value
bool found = false; // Flag to indicate if value was found
while (index < numElems && !found)
{
if (list[index] == value) // If the value is found
{
found = true; // Set the flag
position = index; // Record the value's subscript
}
index++; // Go to the next element
}
return position; // Return the position, or -1