944,110 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 4518
  • C RSS
Jun 29th, 2005
0

linked stack question.

Expand Post »
I've used linked lists before. Does anybody have a resource or url address on how to write a linked stack? I need to create a stack with a menu using int and char variables.

Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yaan is offline Offline
8 posts
since Jun 2005
Jun 29th, 2005
0

Re: linked stack question.

Quote originally posted by yaan ...
I've used linked lists before. Does anybody have a resource or url address on how to write a linked stack? I need to create a stack with a menu using int and char variables.

Thanks.
A stack with a 'menu'? What do you mean by 'menu'?

Creating a linked stack is simple, if you've already written a linked list:

Step 1. Write a linked list.
Step 2. Create a function for pushing an element onto the front of the list. Call this 'push'.
Step 3. Create a function for removing the first element of the list. Call this 'pop'.
Step 4 (optional). Create a function that returns the first element of the list by reference, so it can be used as an lvalue. Call this 'top'.

Viola, you have a linked stack! And of course, with 'function', you can interpret that as 'member function' or 'method': whatever suits you.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Jun 29th, 2005
0

Re: linked stack question.

what I mean by a menu are choices (1 - push a character/integer, 2 - pop a character/integer, 3 - display all, etc..). I assume I'll be using the switch to accomplish this.

Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yaan is offline Offline
8 posts
since Jun 2005
Jun 30th, 2005
0

Re: linked stack question.

yeah
the switch statment shud solve all ur probs..
for any source code u want i think the best site is
www.planetsourcecode.com
u ll get everything in tht site..
Reputation Points: 10
Solved Threads: 1
Light Poster
shre86 is offline Offline
33 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Random Number Guessing Game
Next Thread in C Forum Timeline: Help me in Round Robin Algorithem& Shortest remaining time next





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC