![]() |
linked stack output problems
here is the code
Code:
#include <iostream.h>when i push a number say... 2 4 5 6 the display result is 6->6->6->6-> when i choose pop options the result is The popped element is 6 and i press 2 again to pop out The popped element is 6 (again) is there any mistaken in my code? :crazy: Thanks before |
Re: linked stack output problems
I am not sure but I think display should writer as below:
Code:
case 3: |
Re: linked stack output problems
Is the output really 6->6->6->6->, or is it ->6->->6->->6->->6-> ? Make sure you state EXACTLY the output from the program (for example, you've changed "poped" to "popped", so clearly either you haven't given the output from the program or you've changed the code since posting it).
cout << "->" <<data << "->",temp->data; Interesting use of the comma operator. Maybe have another look at this line? Edit: oh yeah, and you've got a memory leak in case 2. |
Re: linked stack output problems
Here I am posting stack programming singly link list.
From here you can learn it. It will help you to find your mistake in your programe. Code:
#include<conio.h> |
| All times are GMT +5.5. The time now is 16:51. |