I am having trouble insearting a node into a linked list into a specified position:
How can I make this work ?Code:cout << "Enter letter" << endl; // new node for input node *current_in = new node; cin >> current_in -> letter; // input into that new node cout << "Enter position" << endl; int in_pos; cin >> in_pos; node *x = last; // last node node *prev = NULL; int current_node = 0; while (x != NULL) { current_node ++; if (current_node == in_pos) { current_in -> next = x; prev -> next = current_in; } current_in -> next = last; last = current_in; }