Created
August 30, 2017 13:49
-
-
Save mirsahib/b938d7091e31b836ff81c866cacbf31e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void List::insertToNthPosition(int pos,int newData){ | |
temp = new node; | |
temp->data = newData; | |
temp->next = NULL; | |
if(pos==1){ | |
head = temp; | |
}else{ | |
curr = head; | |
for(int i=0;i<pos-2;i++){ | |
curr=curr->next; | |
} | |
temp->next = curr->next; | |
curr->next=temp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
code is not working
Exception thrown: read access violation.
this->temp was nullptr.