I am making a program to take no. of test cases from user and then input in linked list and print them.

this is my code but its not running...
#include<bits/stdc++.h>
using namespace std;
class Node{
public:
int data;
Node* next;
};
Node* push(Node* head1,int data1)
{
if(head1==NULL)
{
cout<<"yes";
(head1)->data=data1;
(head1)->next=NULL;
return head1;
}
else
{
Node* newnode=new Node();
newnode->data=data1;
newnode->next=NULL;
Node* active=new Node();
active=head1;
while(active->next!=NULL)
{
active=active->next;
}
active->next=newnode;
head1=active;
}
}
int main()
{
Node* head=NULL;
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
int a;
cin>>a;
head=push(head,a);
cout<<"no";

}
return 0;
}
The problem is this:

if(head1==NULL)

It should be

if(head1!=NULL) // Note: !=
Topic archived. No new replies allowed.