0

I am trying to search a vector of string names for matches. Names can be more than one word so in prompting the user I am using getline(std::cin, name); however I can never find matches with the existing names in the vector. How do I remove the extra "garbage" from the getline return so it will match with what I have in the vector?

1 Answers1

0

use the delimiter, '\0'.

i.e.:

getline(cin, name, '\0');

and check this out: http://www.cplusplus.com/reference/string/string/getline/

and this: http://www.cplusplus.com/reference/istream/istream/ignore/

Alexandra
  • 56
  • 1
  • 5