code not working
#include<iostream>
using namespace std;
typedef struct node{
int data;
struct node *next;
struct node *previous;
}mynode;
mynode *head,*temp,*current,*tail;
void add(int data);
int main() {
head=NULL;
tail=NULL;
add(1);
cout<<"added 1"<<endl;
add(2);
add(3);
add(4);
}
void add(int data) {
temp=(mynode*)malloc(sizeof(mynode));
temp->next=NULL;
temp->previous=NULL;
if(head == NULL) {
head=temp;
tail = temp;
temp->data=data;
cout<<"Here "<<temp->data<<endl;
}
else {
current=head;
while(current->next==NULL) {
current->next=temp;
temp->previous=current;
temp->data=data;
cout<<"Now "<<temp->data<<endl;
tail=temp;
current=current->next;
}
}
}