string:find

Hi there!

I'm trying to make a function that will search my array for a certain string and then show all the info about the thing thats on that place in the array...
Hard to explain but I would like to accomplish this.

I have an array with lets say 5 slots.
slot1. sofa
slot2. bed
slot3. toilet
slot4. window
slot5. tomato

and now i would like to search for lets say "to".
and it should check my array and when it reaches slot3 it should show everything in that slot and when it reaches slot5 it should do the same.

this is what I've written so far.

1
2
3
4
5
6
7
8
9
10
11
12
void Handler::showString(string str)const
{
	size_t found;
	for(int i=0;i<this->nrOfPresents;i++)
	{
		found=this->prsnt[i]->getIs().find(str);
		if(found!=string::npos)
		{
			this->prsnt[found]->present();
		}
	}
}


hope you understand what I was trying to say.

Best regards Ogward
Topic archived. No new replies allowed.