I'm not going to even try to work out what is wrong with that code: it's just too much trouble of even start reading it, much less work out what parts of it are and aren't relevant.
If you want help, then make it easy for us to help you.
1) Don't dump you whole code on us and expect us to pick out the relevant bits. Show us just the bits that are invloved.
2) INDENT YOUR CODE. When I see stuff like this:
void print(node* head)
{
for (; head; head = head->next)
{
cout << head->e << endl;
}
}
I lose any interest I might have had in wading through code. pick an indentation style and apply it to you whole code to make it a lot easier for us to read, and don't double space it to make it look bigger or more important - again it makes it harder to read:
void print(node* head)
{
for (; head; head = head->next)
{
cout << head->e << endl;
}
}
3) Stop using one letter names - they make it far to easy to make a mistake, and they make code - yet again - harder to read. Use meaningful names that describe concisely what the variable or function does, not "d", "t", "e" ...
4) Saying "it doesn't work" is completely pointless - it tells us absolutely nothing because we have no idea what it is supposed to do, what you did to get it to go wrong, let alone what you have noticed that might be wrong with it.
In essence, help us to help you!