编译器未将有效内存分配给变量

在文件编译器中没有为struct变量分配适当的内存。 在调试时会引发EXC_BAD_ACCESS(代码= 1,地址= 0x8)错误。

评论
  • Ao初见
    Ao初见 回复

    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