I'm creating a structure inside a function and then returning its pointer. For some reason I keep getting the same memory address each time.
typedef struct list_type
{
    node_t *head;
    node_t *tail;
} list_t;
list_t newList() {
    list_t list = {NULL, NULL};
    list_t *listptr = &list;
    printf("newList: %p\n", listptr);
    return listptr;
}
Outputs:
newList: 0x7fffb42c8ae0
newList: 0x7fffb42c8ae0
newList: 0x7fffb42c8ae0
What am I doing?...
 
     
     
     
    