vendredi 26 avril 2019

[C++]Loop until any of the elements of a std::vector is not encountered

I am doing a project in which I have encountered a situation in which I have to loop(inside a function) until some strings arent encountered. The strings are passed in a vector. The problem is, the number of strings is not fixed. How can I get the elements of a vector inside the condition of a loop when I dont know at what subscript to stop? It looks something like this:

while(a != vect[0] && a != vect[1] .... && a != vect[END VALUE]) //loop body Where END VALUE could be anything. Is this possible? Hope i explained my query well. I am using iterators in code. Used subscripts only to explain my query.

Thanks!

Aucun commentaire:

Enregistrer un commentaire