| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 548 人关注过本帖
标题:请高手帮忙啊!
只看楼主 加入收藏
无铭剑客
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2005-10-31
收藏
 问题点数:0 回复次数:0 
请高手帮忙啊!

小弟费了很大的劲才把老师的实验作业编完,谁知一运行真是让人大失所望,一直显示“NULL pointer assginment",检查了一下,没发现有什么错误啊!程序如下,望高手指点迷津,谢谢!

#include "stdio.h"
#include "stdlib.h"
typedef struct node
{int data;
struct node *next;
}linklist;
linklist *head,*new1,*q;
void Init_linklist()
{
char ch;
head=(linklist *)malloc(sizeof(linklist));
q=head;
printf("please input a char:");
ch=getchar();
while(ch!='$')
{
new1=(linklist *)malloc(sizeof(linklist));
new1->data=ch;
q->next=new1;
q=new1;
ch=getchar();
}
q->next=0;
}
void Insertafter(p,x)
linklist *p;
char x;
{ new1=(linklist *)malloc(sizeof(linklist));
new1->data=x;
new1->next=p->next;
p->next=new1;
}
void Delete(p)
linklist *p;
{ new1=p->next;
p->next=new1->next;
free(new1);
}
main()
{ linklist *p;
int i,j,t=0;
char ch;
printf("1:Init_linklist()*****\n");
printf("2:Insertafter() *****\n");
printf("3:Delete() *****\n");
printf("please input 1||2||3 to select the action:");
scanf("%d",&i);
if(i==1)
Init_linklist();
else if(i==2||i==3)
{printf("please input the jidian you want to do or the char you want to insert:");

if(i==2)
{ scanf("%d%c",&j,&ch);
q=head->next;
do {t++; q=q->next;p=q;}
while (q->next!=0&&t!=j);
Insertafter(p,ch);
}
if(i==3)
{scanf("%d",&j);
q=head->next;
do {t++;q=q->next;p=q;}
while (q->next!=0);
}
}
}

搜索更多相关主题的帖子: 检查 include please 
2005-10-31 21:27
快速回复:请高手帮忙啊!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017119 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved