关于单向链表建立的问题
编译环境:vc6.0++目的:单向链表的建立
代码:
#include "stdio.h"
#include <malloc.h>
struct LNode
{
int data;
struct LNode*next;
};
struct LNode*create(int n)
{
int i,a;
struct *head;
struct *p1;
struct *p2;
head=NULL;
printf("Input the integers:\n");
for(i=n;i>0;--i)
{
p1=(struct LNode*)malloc(sizeof(struct LNode));
scanf("%d",&a);
p1->data=a;
if(head==NULL)
{
head=p1;
p2=p1;
}
else
{
p2->next=p1;
p2=p1;
}
}
p2->next=NULL;
return head;
}
main()
{
int n;
struct LNode *q;
printf("Iput the count of the nodes you want to creat:");
scanf("%d",&n);
q=create(n);
printf("The result is:\n");
while(q)
{
printf("%d ",q->data);
q=q->next;
}
getch();
}
问题:语句p1->data=a; 总报错:error C2037: left of 'data' specifies undefined struct/union '$S2'
请知道的指点下为什么