在文件编译器中没有为struct变量分配适当的内存。 在调试时会引发EXC_BAD_ACCESS(代码= 1,地址= 0x8)错误。
编译器未将有效内存分配给变量
评论
请
登录后发表观点
-
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