I know how to use the compare functions to check if a string is exactly the same as another but I wasn't sure if there is an easy way to go about checking if a string contains any sequence of A through F. Can I add up the memory values of A through F and then add them up for whatever variant on them is passed and see if those two values are equal? Thanks for your help.

Now when you say any sequence of A-F do you mean you are only checking 6 characters sized strings like ABCDEF, ACBdEF, ACDBEF, .... If that is the case then something like this should do the trick.

string sequence = "ABCDEF"
string random; // has a random mix of "ABCDEF";
string tester = random;
sort(tester.begin(), tester.end());
if (sequence == tester)
    cout << "has ABCDEF"
else
    cout << "Does not have ABCDEF";

If you are checking a string to see if all of the charactures in it are only A-F then you can use the find_first_not_of() function like this.

string random  = "ABCCCDEFFFABC";
if (random.find_first_not_of("ABCDEF") == string::npos)
    cout << "has only ABCDEF"
else
    cout << "Does not have only ABCDEF";

> Can I add up the memory values of A through F and then add them up
> for whatever variant on them is passed and see if those two values are equal?

No. (why?)

One way is to use the == operator of std::set<>

std::string str = "vjjjJGJGJGJgjjVHhACDBFEfhyffhyfhyfhyf" ;
const std::set<char> abcdef = { 'A', 'B', 'C', 'D', 'E', 'F' } ;

for( auto iter = str.begin() ; iter < str.end() - abcdef.size() + 1 ; ++iter )
{
     if( std::set<char>( iter, iter+abcdef.size() ) == abcdef )
     {
         // found it
     }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.