0

So I had posted a thread here called "Exception Handling" asking for help excuting this program. Then I discovered CodePad! ( So if any of the moderators could help me delete that thread it will be great! )

So I cleared up most of my errors. And I got an output. But I seem to getting a garbage value towards the end.

The objective is basically to handle "stack full" and "stack empty errors". So I push 3 values and I pop 4 values so that I can handle the error using try-throw-catch paradigm.

I'll post my Codepad Link here. Please help!

http://codepad.org/CP23icTR

Edited by livesinabox: n/a

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by livesinabox
0

You're off by 1. When you push the first element, it's at stck[1], because you increment top first. You are reading the values back from stck[2] to stck[0] (which is uninitialised), instead of stck[3] to stck[1].

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.