I have this project where I have push characters onto a stack from phrase until either one of the characters in encrypt1 is encountered that's also in the the phase. Then, it is supposed to stop and pop and print off the characters in the stack until it gets to one of the characters in encrypt2 that's next in the phrase. I get the jist of what I have to do, but I'm having problems thinking of the best way to combine the if statements with the for loops.
So far I've tried combining all of the phrases into one for loop with multiple if, else if's but I think it would be out of bounds since the encrypt1 and encrypt2 strings are always only going to be four characters long and the phrase can be much more then that.
for(c=0;c < phrase.length();c++)
{
if (phrase[c] == encrypt1[c])
myStack.push(phrase[c]);
Any thoughts? Would a while work here with the for loops? Could I take advantage of the fact that encrypt1 & 2 will always be set at four characters?
thanks