Question: I have created a linked list struct in c 

```
struct node{
   int value;
   struct node* next;
};

```

a method to add a node at the start of the list :

```
void addFirst(struct node *list, int value){
    struct node *new_node = (struct node*) malloc (sizeof (struct node));
    new_node->value = value;
    new_node->next = list;
    list = new_node;
   }

```

I create a list (malloc and everything), then call this method, it adds the new node inside the method but when i get back to my main my old list remains unchanged. Using DDD debugger to check everything. How is this possible? I am not able to change the method signature so it has to be done like this.

Answer: 
If you really need to do it this way, you have to re-cast the pointer. Something like this:

```
struct node *my_list = null;
addFirst((struct node *)&my_list, 123);

void addFirst(struct node *list, int value){
    struct node **real_list = (struct node **)list;
    struct node *new_node = (struct node*) malloc (sizeof (struct node));
    new_node->value = value;
    new_node->next = *real_list;
    *real_list = new_node;
}

```
```
void addFirst(struct node **list, int value){
    struct node *new_node = (struct node*) malloc (sizeof (struct node));
    new_node->value = value;
    new_node->next = *list;
    *list = new_node;
}

```

This is the correct code. the problem is that the poineter `struct node *list` You are passing can't be changed as it is a stack variable. If you change it to `struct node **list` you are passing a pointer to the first node of the list. now you can change that to point to the new first node of the list.