Home > Back-end >  C beginners ah, two additive made a list, but... O great god told the reason, I really don't kn
C beginners ah, two additive made a list, but... O great god told the reason, I really don't kn

Time:09-26

#include
#include
#include

Typedef int ElemType;

Struct LNode
{
ElemType data;
LNode * next;
}; Typedef LNode * LinkList;


Void CreateList3 (LinkList & amp; L, int n)
{
int i;
LinkList p, q;
L=(LinkList) malloc (sizeof (LNode));
L - & gt; next=NULL;
Q=L;
Printf (" please lose data \ n % d ", n);
for(i=1; i<=n; I++)
{
P=(LinkList) malloc (sizeof (LNode));
The scanf (" % d ", & amp; p-> The data);
Q - & gt; Next=p;
Q=q - & gt; next;
}
p-> next=NULL;
}

Void CreateList2 (LinkList & amp; L, int n)
{
int i;
LinkList p, q;
L=(LinkList) malloc (sizeof (LNode));
L - & gt; next=NULL;
Q=L;
Printf (" please enter data into % d \ n ", n);
for(i=1; i<=n; I++)
{
P=(LinkList) malloc (sizeof (LNode));
The scanf (" % d ", & amp; p-> The data);
Q - & gt; Next=p;
Q=q - & gt; next;
}
p-> next=NULL;
}

Int ListTraverse (LinkList L)
{
LinkList p;
P=L - & gt; next;
While (p)
{
Printf (" % d ", p - & gt; The data);
P=p - & gt; next;
}
printf("\n");
return 1;
}
Void UnionList (LinkList * La, LinkList * Lb, LinkList * & amp; Lc)
{
Int I=0, j=0, k=0;
Lc=(LinkList *) malloc (sizeof (LinkList));
While (i{
If (La - & gt; Data [I] {
Lc - & gt; Data [k]=La - & gt; Data [I];
I++ k++;
}
The else
{
Lc - & gt; Data [k]=Lb - & gt; Data [j];
J++ k++;
}
}

While (i{
Lc - & gt; Data [k]=La - & gt; Data [I];
I++ k++;
}
While (j{
Lc - & gt; Data [k]=Lb - & gt; Data [j];
J++ k++;
}
Lc - & gt; Length=k;
ListTraverse (Lc);

}
Int main ()
{
Int n=5;
LinkList La;
LinkList Lb.
LinkList Lc;

CreateList2 (La, n);
CreateList3 (Lb, n);
Printf (" La=");
ListTraverse (La);
Printf (" Lb=");
ListTraverse (Lb);
Printf (" Lc=");
UnionList (La and Lb, Lc);


return 0;

The error C2227: "- & gt; Length must point to the left side of "class/structure/joint/generic type
1> Type is "LinkList *"
  • Related