Thread: Stack Question

  1. #1
    Registered User
    Join Date
    Aug 2001

    Stack Question

    I understand hoew a stack works but my question is, How is a stack used in a real programming situation? If you can give me an example (not code). If you wrote a operating system like Windows 2000, what does the stack code do in the program?

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    It can be used in game programming. Say for example you had a deck of cards. You would impliment a stack and deal the top card until the stack was empty.

    Regarding OS's. I know that there is a memory function stack that stores variables. When the scope of the function terminates than the variables are released from the stack. Operating sytem internals is a big subject:

    Inside Windows 2000 Thrid edition by Solomon and Russinovich

  3. #3
    Join Date
    Aug 2001
    Every c function you write most likely pushes args on the stack and then pops the stack. On intel chips the call and later ret works by storing the address of the function on the stack. Any other way would probably make recursion hard to implement.

  4. #4
    Registered User
    Join Date
    Aug 2001
    compilers also use em to evaluate expressions.

  5. #5
    Zeeshan Ziaq

    Red face

    A recursive function uses it to save to values of the parameters given to a particular instance....and other vars tooo....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a stack question
    By JJH35 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2007, 11:37 PM
  2. Linked list Stack question
    By lyrick in forum C++ Programming
    Replies: 4
    Last Post: 09-23-2005, 06:23 AM
  3. Question about stack - push - pop
    By The Wiep in forum C++ Programming
    Replies: 6
    Last Post: 12-29-2002, 12:08 PM
  4. HEap and stack, I'm confused
    By indigo0086 in forum A Brief History of
    Replies: 3
    Last Post: 10-31-2002, 10:59 AM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM