admin管理员组文章数量:1794759
报错runtime error: member access within misaligned address(以及结构体使用)
在写一个 链表 相关的题目时犯的错误。
runtime error: member access within misaligned address 0xbebebebebebebebe for type 'struct ListNode', which requires 8 byte alignment (ListNode.c) 0xbebebebebebebebe: note: pointer points here这是为啥呢;因为没有赋初值
假设这么个结构体
struct ListNode { int val; struct ListNode *next; };你创建一个结构体变量,这样才正确
struct ListNode *p,*q; p=(struct ListNode * )malloc(sizeof(struct ListNode)); p->next=NULL;如果不给p赋初值的话会报这个错!
再多嘴一句,创建结构体记得加struct
struct ListNode *p;
p=(struct ListNode * )malloc(sizeof(struct ListNode));
版权声明:本文标题:报错runtime error: member access within misaligned address(以及结构体使用) 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686961810a122684.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论