You have:
while(current != NULL)
{
if (current->rating == rating)
{
flag = 1;
break; }
}
The
break
in the
while
loop terminates the loop, so you only get the first matching item. You probably want to remove that.
Why not use an STL container e.g.
std::list
or a
std::vector
, then use
std::copy_if
to create a new container with the matching items in it?