You never initialized head, so it points to some random location. You should do something along the lines of head = (doubly_linked_list*)malloc(sizeof(doubly_linked_list)) first. This will allocate a new doubly_linked_list struct and assign it to head. And of course you probably need to free it later
You never initialized
head
, so it points to some random location. You should do something along the lines ofhead = (doubly_linked_list*)malloc(sizeof(doubly_linked_list))
first. This will allocate a newdoubly_linked_list
struct and assign it tohead
. And of course you probably need tofree
it later