0

Hi,

i'm trying to delete last node of linked list and print the remaining list at each step.

for this i created 'Print' function.

please take a look at this code:

```
struct Node{
int data;
Node *next;
};
void Print(Node *head){
if(head==0) return;
else{
Node *temp=head;
Node *prev=head;
while(temp!= NULL){ cout<<temp->data<<" ";temp = temp->next;}
//cout<<"..."<<endl;
temp=head;
while(temp->next!=0){
prev=temp;
temp=temp->next;
}
delete temp;
temp=0;
prev->next=temp;
Reverse(head);
}
}
int main() {
int n;
cin>>n;
int num;
Node *head=0;
for(int i=0;i<n;i++){
cin>>num;
Node *temp=new Node();
temp->data=num;
temp->next=head;
head=temp;
}
Print(head);
return 0;
}
```

someone please tell me .....why the hell it's not working???....... :(