![]() |
| | #1 |
| Registered User Join Date: Sep 2009
Posts: 13
| top of stack |
| greatunknown is offline | |
| | #2 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,642
| Keep a pointer to the the top of the stack. It depends on how you are implementing it. You'll need to be more specific. By 'top' do you mean the last thing you have pushed, or the first thing? Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? |
| quzah is offline | |
| | #3 |
| Registered User Join Date: Sep 2009
Posts: 13
| so i have an empty stack, i need "char d" to be assigned to the top of the stack, meaning the last thing pushed, in order to compare it with something else without having to pop the stack and then compare how should char "d" be assigned? |
| greatunknown is offline | |
| | #4 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,642
| You could write a peek function that returns the last item entered into the stack, without actually removing it. But if you're going to try to compare multiple items, or chains of items, I don't know that a stack is really what you want. Generally you just push whatever you want on the stack, and then you pop the top on and compare it. Code: type peek( stack *s )
{
return s->top;
}
Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? |
| quzah is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Fixing my program | Mcwaffle | C Programming | 5 | 11-05-2008 03:55 AM |
| stack and pointer problem | ramaadhitia | C Programming | 2 | 09-11-2006 11:41 PM |
| Question about a stack using array of pointers | Ricochet | C++ Programming | 6 | 11-17-2003 10:12 PM |
| error trying to compile stack program | KristTlove | C++ Programming | 2 | 11-03-2003 06:27 PM |
| Stack Program Here | Troll_King | C Programming | 7 | 10-15-2001 05:36 PM |