Vector - iterator

I have 3 different vectors, V1, V2 and V3. V1 and V2 have the same size and each line refers the same record. I would like to write a function that get each line from V3 and check if exists in V2, and if is == "M" in V1.

That sounds very abstract for anyone to help you. How do you know you have memory issues? I can't make out any memory issues from the code snipped you have given here. You should though check if your iterator points to end() before you dereference it.