0
#include<conio.h>
#include<stdio.h>
#include<alloc.h>
typedef struct node
{
int data;
struct node *n_next,*next,*p_pre,*pre;
};
int main()
{
node *head,*p,*q,*r,*s;
head=(struct node*) malloc(sizeof(struct node));
p=head;
q=(struct node*) malloc(sizeof(struct node));
r=(struct node*) malloc(sizeof(struct node));
s=(struct node*) malloc(sizeof(struct node));
printf(" \nEnter the data of the node ");
scanf("%d",&p->data);
printf("\nEnter the data for second node ");
scanf("%d "&q->data);
printf("\nEnter the data for third node ");
scanf("%d "&r->data);
printf("\nEnter the data for fourth node ");
scanf("%d ",&s->data);
getch();
return(0);
}
编译后,代码需要取4个数据值,并将其存储在推崇节点的数据字段,但它说..这是为什么不工作?[链表]
scanf(“%d”,& p-> data); //非法使用指针?这是怎么回事?
代码的哪部分被破坏,应该修复?
你还没有为'结构赋予了typedef名称:
和你自己的
scanf
一些调用缺少逗号node'。 – 2013-03-15 14:23:46那么应该指定什么呢? – Ivean 2013-03-15 14:24:18
查看teppic的回答。 – 2013-03-15 14:24:42