This code is not taking input in buildlist. Please help me with what is the issue

#include
using namespace std;

class node{
public:
int data;
node *next;
node(int val){
data=val;
next=NULL;
}
};

void buildList(node* &head, int n){
int val;
node* head1;

for(int i=0;i<n;i++){
	cout<<"i="<<i;
	cin>>val;
	cout<<"value=";
	node* temp= new node(val);
	if(head==NULL)
		head=temp;
	else{
		head1=head;
		while(head1->next!=NULL)
			head1=head1->next;
		head1->next=temp;
	}
}
return;

}

void appendKlist(node* &head,int k){
node *slow=head,*fast=head,*prev;
while(k>0){
fast=fast->next;
}
while(fast!=NULL){
prev=slow;
slow=slow->next;
fast=fast->next;
}
slow=head;
head=slow;
prev->next=NULL;
}

void print(node* head){
cout<<“list is”<<endl;
while(head!=NULL)
cout<data<<" ";
}
int main(){
#ifndef ONL
freopen(“input.txt”,“r”,stdin);
freopen(“output.txt”,“w”,stdout);
#endif
node*head=NULL;
int n;
cin>>n;
buildList(head,n);
cout<<“list is”<<endl;
print(head);
int k;
cin>>k;
if(n<k)
//appendKlist(head,k);
print(head);
return 0;
}

Save your code on ide.codingblocks.com and then share its link.