I have to develop a linked list similar to one I found asked about on this site:

xor linked list

Mine has a twist though.

The function signatures include pointers to pointers for the head and tail, along with the integer number.

Here is my source.

Code:

#include <stdio.h>
#include "rndm.h"
#include <stdlib.h>
#define init_seed
#define set_range
#define SIZERANGE 100
typedef struct node
{
int data;
unsigned long link;
}node ;
node *head, *tail;
void insert(node **head,node **tail, int n)
{
node *prev, *cur, *next, *tmp;
node *newnode = malloc(sizeof(node));
head = &cur;
prev = NULL;
while(cur->data < n)
{
next = (node *)(cur->link ^ (unsigned long)prev);
prev = cur;
cur = next;
}
newnode->link ^= (unsigned long) prev ^(unsigned long) cur;
prev->link ^= (unsigned long) cur ^ (unsigned long) newnode;
cur->link ^= (unsigned long) prev ^ (unsigned long) newnode;
}//end insert
void delete(node **head, node **tail, int n)
{
}
void list(node *head)
{
}
main ()
{
head=NULL;
tail=head;
int startRange, endRange, n,i;
long inputSeed;
printf("Seed: ");
scanf("%l\n", &inputSeed);
init_seed(inputSeed);
printf("Range: ");
scanf("%d %d\n", &startRange, &endRange);
set_range(startRange, endRange);
for(i=0; i <= SIZERANGE; i++)
{
insert(&head, &tail, rndm());
}
}

I am only working on the insert method at this time. I am kind of just code pushing for the declarations in that function, no really knowledge on what I should be doing. I am very confused with the **head and **tail variables.

Can someone kind of give me a push in the right direction concerning how this function should be operating and the variable declarations?

Thanks!