First of all, you are confused as to what a linked list is. There is no array in a linked list, so you can get rid of all references to ptc.
A linked list is a set of nodes. Each node has a value and a pointer to the next node in the list. That is what you defined in lines 6 - 12.
Before you can delete nodes from a linked list, you have to add nodes to the linked list first. When you add a node, you must allocate the node (using new), assign the "next" pointer of the previous node to the address of the new node, and assign the "next" pointer of the new node to what the previous node used to point to.
There is also the special case of inserting a node as the first element of an existing list (including the first element of an empty list).
I would suggest the following starting point:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
/* various includes */
struct node ... /* same as what you have */
void addToBack(node** theList, int value)
{
.... /* This is what you have to implement */
}
int main()
{
node* head = NULL; /* Start with an empty list */
for (int i = 0; i < 3; ++i)
{
addToBack(&head, i);
}
}
| |
Figure out how to add nodes to the list, and then print them out to make sure you have them inserted properly. After that you can start thinking about removing the nodes.