Again me with vectors. I hope I’m not too annoying. I have a struct like this :
struct monster { DWORD id; int x; int y; int distance; int HP; };
So I created a vector :
std::vector<monster> monsters;
But now I don’t know how to search through the vector. I want to find an ID of the monster inside the vector.
DWORD monster = 0xFFFAAA; it = std::find(bot.monsters.begin(), bot.monsters.end(), currentMonster);
But obviously it doesn’t work. I want to iterate only through the .id element of the struct, and I don’t know how to do that. Help is greatly appreciated. Thanks !
std::find_if:Or write your own function object if you don’t have boost. Would look like this