ptr points to the node you're going to remove. You know this isn't the first node by that point, so you need to make sure that the node before ptr links to the node after ptr. You are not doing that, although you clearly meant to; you just didn't write the statement correctly.