Stack Question

This is a discussion on Stack Question within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I understand hoew a stack works but my question is, How is a stack used in a real programming situation? ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    84

    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
    Posts
    1,784
    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:

    Book:
    Inside Windows 2000 Thrid edition by Solomon and Russinovich

  3. #3
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    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
    Posts
    61
    compilers also use em to evaluate expressions.

  5. #5
    Zeeshan Ziaq
    Guest

    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, 11:08 AM
  4. HEap and stack, I'm confused
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 10-31-2002, 09:59 AM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21