i need to ask the user for some characters that can be infinitely long. then i need to validate that the string only has certain letters. this is like dna sequence. i also have in my class vector<string>DNA.
can someone help me, because i think the problem here is i am using strings which i need but validating only with one letter
See the documentation for find_first_not_of http://www.cplusplus.com/reference/string/string/find_first_not_of/ Obviously, you want your list to contain only "acgt".
But you need to rethink the logic of your program:
- if I enter say "x", on line 6 you assign DNA="x", then since it is not "a" or "c", it will ask again, and I can put "y", so DNA="y" on line 10, and on line 12 DNA="yy"
- if I enter "a", the loop between lines 8 to 11 is not executed, but on line 12 DNA will become "aa"