Not sure why you need to jump from state to state like that? Is this some sort of finite automaton?
The function you are using to find something in another string is wrong. strcmp compares two strings for equality and returns a value depending on the comparison. http://www.cplusplus.com/reference/cstring/strcmp/