#include <bits/stdc++.h>
using namespace std;
struct node {
string s;
node* link;
}*top=NULL,*temp,*p;
node* new_node(node a){
p=new node;
p->s=a.s;
p->link=a.link;
top=p;
}
void showstack(){
*temp=*top;
while(temp!=NULL){
cout<<top->s;
temp=top->link;
}
}
int main(){
char a;
int m;
int i=0;
node push;
do{ std::cin >> push.s;
if(top==NULL)
push.link=NULL;
else
push.link=top;
new_node(push);
i++;
}while(i<=5);
cout<<top->s;
showstack();
return 0;
}
i wrote the above code trying to implement a linked stack in c++ however after giving the input the program is hanging and no response.why is it so? i checked and rechecked many times and found no bug.pls help!!