#include<stdlib.h>typedef struct node{
int data;
struct node *front,*next;
}node,*linkHead;void creatList(linkHead *head,int n)
{
int c=0;
linkHead p;
linkHead h=(linkHead)malloc(sizeof(node));
h->front=NULL;
while(c <= n){
c++;
if(c == 1) *head=h;
else{
p=(linkHead)malloc(sizeof(node));
scanf("%d",p->data);
h->next=p;
p->front=h;
h=p;
}
}
}
main()
{
linkHead list;
creatList(&list,4);
}大家看看这个程序为什么运行时在第二个输入后就出错了。
int data;
struct node *front,*next;
}node,*linkHead;void creatList(linkHead *head,int n)
{
int c=0;
linkHead p;
linkHead h=(linkHead)malloc(sizeof(node));
h->front=NULL;
while(c <= n){
c++;
if(c == 1) *head=h;
else{
p=(linkHead)malloc(sizeof(node));
scanf("%d",p->data);
h->next=p;
p->front=h;
h=p;
}
}
}
main()
{
linkHead list;
creatList(&list,4);
}大家看看这个程序为什么运行时在第二个输入后就出错了。
解决方案 »
- java swing中 jTable 的使用问题
- 望高手能以下面例子解释下锁机制
- 超简单错误,但不知道错在哪里? 15分钟后结贴
- 请教关于socketserverchannel处理长连接问题
- 能转成exe文件吗?
- 如何将tomcat8080端口改成8090?
- 有关HashMap的一个method:entrySet()
- 在Java程序中,我应该怎样实现四舍五入,保留小数点后1位小数?
- 谁有jpro的注册码?急。
- 求助:Exception in thread "Thread-3" java.lang.NullPointerException
- 好久不来CSDN了,VB转JAVA了
- 如何判断一个Integer对象中的数据是半角数字???
还有你的malloc写的不对吧
int data;
struct node *front,*next;
}node,*linkHead;void creatList(linkHead *head,int n)
{
int c=0;
linkHead p;
linkHead h=new node();
h->front=NULL;
while(c <= n){
c++;
if(c == 1) *head=h;
else{
p=new node();
cin>>p->data;
h->next=p;
p->front=h;
h=p;
}
}
}
main()
{
linkHead list;
creatList(&list,4);
}