Skip to main content
gamedev.net
🔒 Locked

Printing the stack

Started by pdstatha 1 reply 200+ views
Original Post
pdstatha
pdstatha
Is there anyway of printing the contents of the stack without having to pop the top elements off as you go along??
IndirectX
IndirectX
A general stack implementation (like std::stack) only provides push, pop, and top methods, so in general the answer is no.
---visit #directxdev on afternet <- not just for directx, despite the name
Inmate2993
Inmate2993
Which stack are you talking about? If it''s the run-time stackframe, I couldn''t help you, but I''m sure that there is plenty of debugging information out there on the web. As for any stack implementation, like the post above me says, no. However, if you make your own stack code, just remember to have accessor functions that point at the first element in the stack, and have it built with a linked-list form so you could traverse through the stack without changing the location of any of the elements. If thats a no go, then setup a second stack, and do a
POP FROM A, PUSH TO B, REPEAT UNTIL A IS EMPTY,
POP FROM B, PRINT, PUSH TO A, REPEAT UNTIL B IS EMPTY.
But thats inefficient and you already stated that you didn''t want that.

-> Will Bubel
-> Machine wash cold, tumble dry.
william bubel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.