//push.c //John T. Rine //October 12, 2011 #include #include #include"all.h" void push(node **head, node **tail, /*int position,*/ int data) { int i; node *temp, *temp2; temp = temp2 = NULL; temp = *head; //for(i = 0; i < position; i++) //{ // temp = temp -> next; //} while(temp != NULL) { temp = temp->next; } if (*head == NULL) { *head = (node *) malloc(sizeof(node)); *tail = *head; (*head)->prev = NULL; (*head)->next = NULL; (*head)->data = data; } else// if (*tail == temp) { temp2 = (node *) malloc (sizeof(node)); temp2->prev = *tail; temp2->next = NULL; (*tail)->next = temp2; *tail = temp2; (*tail)->data = data; } //else //{ //temp2 = (node *) malloc (sizeof(node)); //temp2->prev = temp; //temp2->next = temp->next; //temp->next->prev = temp2; //temp->next = temp2; //temp2->data = data; //} }