Here is my code to make it better to understand (Hopefully)

Code:

node *newnode = current;
node *temp = current;
node *start = current;
int number = 0;
int num = 0;
for (int i = 1; i < length; i++) // this function is just ensuring the node before the deleted node points to 2 nodes in front
{
temp = temp -> shortlink;
}
if (newnode -> num == x)
{
number = current -> longlink -> num; // here as you can see i want to store the longlink value of the deleted node into the variable number
current = current -> shortlink;
temp -> shortlink = start -> shortlink;
delete newnode;
length--;
}
else
while (newnode -> shortlink -> num != start -> num)
{
if (newnode -> shortlink -> num == x)
{
temp = newnode -> shortlink;
number = temp -> longlink -> num; // here as you can see i want to store the longlink value of the deleted node into the variable number
newnode -> shortlink = newnode -> shortlink -> shortlink;
delete temp;
length--;
}
newnode = newnode -> shortlink;
}
if (newnode -> shortlink -> shortlink -> num == length && newnode -> shortlink -> num == x)
{
delete newnode -> shortlink -> shortlink;
newnode -> shortlink = start;
length--;
}
for (int z = 1; z < length; z++) // this function goes through each node to see if any of the long links are pointing to the deleted node
{
// if i put a cout statement exactly here to cout number - it recognises the number variable fine
if (longlinker -> longlink -> num == x) // if i've found it // once it looks into this if statement - number isn't recognised - why?
{
longlinker -> longlink -> num = number; // then i want to update the longlink of this which stores number
}
else
{
longlinker = longlinker -> shortlink; // otherwise keep iterating
}
}