What variable type is newPtr and tempPtr?
Do they have a structure definition or is there a class definition?
Can you give the context of when this code is executed?
Looks to me like it is inserting a new node at index n-2. So if there were n nodes in the list, then the code would insert newPtr as the second to last element in the list.