新人求教,链表生成问题

qq_20003349 2018-04-29 02:53:19
求教,为什么我写的链表生成代码,生成后访问时会出现段错误?
代码如下

void Create_Store(int numberof,struct struction * allbeginning)
//numberof 为需要单位个数,allbeginning 为预留的链表开头
{
int timer=1;
struct struction * arralla=(struct struction *)malloc(sizeof(struct struction));

allbeginning=arralla;

while(timer<numberof)
{
arralla->arrnext=(struct struction *)malloc(sizeof(struct struction));

(arralla->arrnext)->arrlast=arralla;
arralla=arralla->arrnext;
timer++;
}
...全文
794 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2018-04-30
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处,看不懂时双击下一行,直到能看懂为止
qq_20003349 2018-04-29
  • 打赏
  • 举报
回复
抱歉发错了。更正如下
void Create_Store(int numberof,struct struction * allbeginning,struct struction * arralla)
//numberof 为需要单位个数,allbeginning 为预留的链表开头
    {
        int timer=1;
        arralla=(struct struction *)malloc(sizeof(struct struction));
        
        allbeginning=arralla;
        allbeginning->arrlast=NULL;

            while(timer<numberof)
                {
                    
                    
                    arralla->arrnext=(struct struction *)malloc(sizeof(struct struction));
                    (arralla->arrnext)->arrlast=arralla;
                    (arralla->arrnext)->arrnext=NULL;
                    
                    arralla=arralla->arrnext;
                    
                    timer++;
                   
                }

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧