I've implemented a Brute Force search into my double ended list class but have encountered a small issue. When I return the value, it returns the rest of the end of the string also, not just that one element. I'm not sure what's causing this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ListElement *BruteSearch(constchar* string)
{
ListElement *iter = new ListElement;
iter = this;
while(iter != NULL)
{
if(strcmp(string, iter->mData) == 0)
return iter;
iter = iter->Next();
}
return 0;
}
ListElement *BruteSearch(constchar* string)
{
ListElement *iter = new ListElement; //allocate a new element
iter = this; //loose the reference to the new element
}
When I return the value, it returns the rest of the end of the string also, not just that one element