I'm a student working on STL containers which were not formally taught in class. The website I typically follow hasn't helped, and neither have my textbooks. I'm getting an assertion error with this "while" loop. Probably something obvious to someone who works with C++ STL...
There's an explanation for all the outcomes I tried at the bottom. If you have a good reference site you use for this type of thing PLEASE pass it on? Thanks!

while((!MStack.empty()) && (!FStack.empty()))
			  {
				 cout << " " << MStack.top();
				 LStack.push(MStack.top());  //push to left stack
				 //MStack.pop();
			  
				 cout << " " << FStack.top();
				 RStack.push(FStack.top());	//PUSH to right stack
				 //FStack.pop();
				 			 
				 cout << " " << MStack.top();
				 RStack.push(MStack.top());	//PUSH to right stack
				 //MStack.pop();

				 cout << " " << FStack.top();
				 LStack.push(FStack.top());  //PUSH to left stack
				 //FStack.pop();
			 }

//WHEN PUSH EDITED THE LOOP EXECUTES CORRECTLY AND THEN THE ASSERTION ERROR HAPPENS
//WHEN BOTH SECOND LINES ARE EDITED OUT, OR JUST THE POP LINE - NEVERENDING LOOP

OUCH! YOU HEART MY ERARS WITH YOUR SHOUTING!!!

1) post error message(s)

2) post enough code to illustrate the problem. We have no clue what STL contains you are using.

As far as I know, the only debug assertion in common STL stack container implementations rises when you try to pop an empty stack (Expression: deque empty before pop in Plauger's STL impl.).
So revise your algorithm, trace test run step by step with debugger. I think, it's not so hard work...

Very sorry - I use the caps for my own eyes - so I don't miss something I think is important.

C++ STL.

Without a print screen I can't show you the error - MS Visual Studio and because of my lack of STL knowledge, I can't get the gist of the error. I apologize for this as well.

>>C++ STL.
That tells us nothing. There are quite a few container classes in that. What is MStack? and the other things in your post.

>>Without a print screen I can't show you the error
Just hit the PrintScreen key on your keyboard, copy to MS-Paint, in MS-Paint save to file, then attach that file to your post. To do that, hit the "Go Advanced" button, scroll down to "Manage Attachments".

Well if you run the code in the debugger, it will trap the assert and point you at the line of code which is the problem.

Since this is in the STL, you then bring up the stack trace window, and navigate up the stack a couple of levels to you reach your code.
Then figure out what you did wrong (as per the suggestions already made)

This article has been dead for over six months. Start a new discussion instead.