How to insert user defined function insertatmiddle in program

#include

using namespace std;
int main(){
struct node{
int data;
struct nodenext;
};
int choice=1;
struct node
head=NULL,*newnode,temp;
while(choice){
newnode=(struct node
)malloc(sizeof(struct node));
cin>>newnode->data;
newnode->next=0;
if(head==0)
{
head=temp=newnode;
}
else {
newnode->next = head;
head = newnode;
}
cout<<“do you want to continue”<<endl;
cin>>choice;
}
temp=head;
while(temp!=0)
{
cout<data;
temp=temp->next;
}

}
//how to insert the following function in program

void insertatmiddle(int data, struct node*head,new node){
struct node
head,new node;
newnode=(struct node
)malloc(sizeof(struct node))
cin>>newnode->data;
newnode->next=head;
head=newnode;
}

Hi @supratik260699
To insert this function first you have to declare this function before the main function. That is before int main write void void insertatmiddle(int data, struct node*head,struct node new_node); and in the main function where you want to make a call to this function you have to just make a call in which you pass all these arguments. That is if data is d and new node is n then write insertatmiddle(d,head,n); .
Also in this function you dont need to declare new node and head again because they are already present as the argument so just use them no need of
struct node
head,new node;
newnode=(struct node
)malloc(sizeof(struct node));