Qustion about set function!!

Hi I have a question about set function!!
I got an assignment for my programming class that is to make Finite State machine!!
Professor provided the header file that contains each state and set<char> that has each alphabet and number..!!

The question is how do I compare an input character and the character inside the set<char>??

lets say if I have set<char> alphabet;
And inside the alphabet = 'A', 'B', 'C', ... 'x', 'y', 'z'!!!!
I tried this!
Get an input, c = 'b';
set<char>::iterator alph;
alph = alphabet.find(c);

if(c == *alph){
.
.
.
do stuff
}

Does anyone know whats wrong??
Searches the container for an element with a value of x and returns an iterator to it if found, otherwise it returns an iterator to set::end (the element past the end of the container).

http://cplusplus.com/reference/stl/set/find/

set::find(c) return set::end if c is not found, so instead of if(c == *alph) try if(alph != alphabet.end())
Last edited on
Thank you very much!!
Topic archived. No new replies allowed.