Sep 23, 2016 at 3:11am UTC
So my assignment is to search an inputed DNA string for the characters "A G T C" using a bool function but no matter what I try, I cannot get the string find function to work.
[code]
#include <iostream>
#include <string>
using namespace std;
string enterDNAString(string DNAsequence)
{
cout << "Enter DNA sequence: ";
cin >> DNAsequence;
cout << "Your DNA sequence is: " << DNAsequence;
cout << " (" << DNAsequence.size() << " characters)";
return DNAsequence;
}
bool checkValidity(string s)
{
size_t pos = s.find_first_of("agtcAGTC");
if (pos != string::npos)
{
cout << " Valid DNA";
}
if (pos == string::npos)
{
cout << " Invalid DNA";
}
return 0;
}
int main()
{
string DNAsequence = "";
enterDNAString(DNAsequence);
checkValidity(DNAsequence);
return EXIT_SUCCESS;
}
Sep 23, 2016 at 3:39am UTC
string enterDNAString(string DNAsequence)
Should be :
string enterDNAString(string &DNAsequence )
Sep 23, 2016 at 12:57pm UTC
Thank you, my code works now!