/**
* findWaldo
*
* Search for the name "Waldo" in a list of names. If found, save the
entire
* list to an external file called "nameslist.txt".
*
* @param nameList - list of names ("Alice", "Bob", etc.)
* @param searchFrom - index in the list from which to search
* @return true if "Waldo" is in the list, false otherwise
*/
bool findWaldo(NameList* nameList, int searchFrom)
{
if(nameList->size() > 1000)
// list is too big
return false;
File* myFile = new File("nameslist.txt");
bool found;
for(int i = 0; i <= nameList->size(); i++)
{
if(nameList->getItem(i) == "waldo")
{
found = true;
if(!nameList->writeToFile(myFile))
{
ERROR("Could not write to file");
return found;
}
}
}
delete myFile;
return found;
}