Hey guys, sorry for, but I'm new to doubly-linked lists and was wondering if anyone could tell me why my program crashes when i use add_end()?
#include <iostream>
using namespace std;
node *start_ptr = NULL;
node *current;
int option = 0;
void add_end()
{
node *temp, *temp2;
temp = new node;
cout << "Enter name: ";
cin >> temp->name;
cout << "Enter profession: ";
cin >> temp->profession;
cout << "Enter age: ";
cin >> temp->age;
temp->nxt = NULL;
if (start_ptr = NULL)
{
start_ptr = temp;
current = start_ptr;
}
else
{
temp2 = start_ptr;
while (temp2->nxt != NULL)
{
temp2 = temp2->nxt;
}
temp2->nxt = temp;
temp->prv = temp2;
}
}