Thread: throw underflow?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    28
    So let's say we're using a stack that fluctuates, as in infix to postfix expression conversions. At any given moment the stack may be empty, and if so it would abort because of the underthrow? What would be a good alternative?

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by stefanyco View Post
    So let's say we're using a stack that fluctuates, as in infix to postfix expression conversions. At any given moment the stack may be empty, and if so it would abort because of the underthrow? What would be a good alternative?
    In that case, the only reason the stack becomes empty before being popped is due to a syntax error in the input, which IMHO warrants an exception.

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Wow, a lot of very interesting topics expressed here. Back to the actual question:
    Quote Originally Posted by stefanyco View Post
    So let's say we're using a stack that fluctuates, as in infix to postfix expression conversions.
    Why, are you using an explicit stack for this? This can easily be handled via a series of function calls, as in most constructs of this type. What topic are you trying to learn?

    Quote Originally Posted by stefanyco View Post
    At any given moment the stack may be empty, and if so it would abort because of the underthrow? What would be a good alternative?
    Well, that depends on how you have setup your program. Where is it that you use your try-catch block? Do you even understand how they work?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack underflow
    By homer_3 in forum C Programming
    Replies: 5
    Last Post: 09-02-2009, 01:28 PM
  2. popen and fgets, underflow!
    By henrikstolpe in forum Linux Programming
    Replies: 0
    Last Post: 02-06-2009, 03:39 AM
  3. handling overflow, underflow etc
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 07-03-2008, 07:10 AM
  4. stack underflow issue
    By camo in forum C Programming
    Replies: 13
    Last Post: 10-31-2005, 06:53 AM
  5. memory underflow.
    By newbie_grg in forum C++ Programming
    Replies: 4
    Last Post: 01-26-2003, 11:19 AM