here is the code
Code:
#include <iostream.h>
#include<stdlib.h>
#include<conio.h>
struct node
{    
int data;
    struct node *link;
 };
 struct node *top=NULL,*temp;
 void main()
 {    int choice,data;
     
          while(1)//infinite loop is used to insert/delete infinite number of nodes    
    {                cout << "\n1.Push\n2.Pop\n3.Display\n4.Exit\n";        
    cout << "\nEnter ur choice:";        
    cin >> choice;        
    switch(choice)        
{  case 1:
   temp=(struct node *)malloc(sizeof(struct node));
   cout << "Enter a node data :";
   cin >> data;
   temp->data=data;
   temp->link=top;
   top=temp;   
                    
break;   
                 
 case 2:    
   if(top!=NULL)           
   {   
                 
     cout << "The poped element is " << data,top->data;
   
      top=top->link;            
   }          
      else           
    {        cout << "\nStack Underflow";                }  
             break;   
                      
 case 3: 
          temp=top;  
    if(temp==NULL)      
 {        cout << "\nStack is empty\n";  }   
       while(temp!=NULL)  
 {               
    cout << "->" <<data << "->",temp->data; 
                temp=temp->link;            }   
          break; 
           
 case 4:       
  
   exit(0);        }           
       
  }  
    }
here's the problem
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?
Thanks before