I want to ask list
Structure that define
Typedef int ElemType;//the type of data elements for integer
Typedef struct LNode {
ElemType data;//data domain
Struct LNode * next;//pointer field
} LNode * LinkList;//LinkList for pointer to structure LNode type
Functions are defined first such
Void MergeList_L (LinkList LA LinkList LB, LinkList & amp; LC)
My own definition of LinkList p;
I want to how to make p=LC;
Thank you for your help
CodePudding user response:
First create the linked list, the list of traverse write come out,
Try to write a list merger
CodePudding user response:
reference 1/f, confident boy reply: first create the linked list, the list of traverse write come out, List merge try to write Ok, thank you CodePudding user response:
According to the can ah, you wrote for reference: typedef int ElemType;//the type of data elements for integer Typedef struct LNode { ElemType data;//data domain Struct LNode * next;//pointer field } LNode * LinkList;//LinkList for pointer to structure LNode type Void MergeList_L (LinkList LA LinkList LB, LinkList & amp; LC)//function definition { LinkList p; P=LC; } //my own definition of LinkList p; //I want how to make p=LC; Int main () { LinkList La=(LinkList) malloc (sizeof (LNode)); LinkList Lb=(LinkList) malloc (sizeof (LNode)); LinkList Lc=(LinkList) malloc (sizeof (LNode)); MergeList_L (La and Lb, Lc); system("pause"); } CodePudding user response:
reference QZJHJXJ reply: 3/f press can ah, you wrote for reference: typedef int ElemType;//the type of data elements for integer Typedef struct LNode { ElemType data;//data domain Struct LNode * next;//pointer field } LNode * LinkList;//LinkList for pointer to structure LNode type Void MergeList_L (LinkList LA LinkList LB, LinkList & amp; LC)//function definition { LinkList p; P=LC; } //my own definition of LinkList p; //I want how to make p=LC; Int main () { LinkList La=(LinkList) malloc (sizeof (LNode)); LinkList Lb=(LinkList) malloc (sizeof (LNode)); LinkList Lc=(LinkList) malloc (sizeof (LNode)); MergeList_L (La and Lb, Lc); system("pause"); } Friend, I that LC is take address (you can see is & amp; LC), then p is variable of LinkList, should be a pointer variables * p, but LinkList itself and pointer variable, defined as pointer variable p I don't know how the components in the reference structure, so I want to ask how to make p=LC CodePudding user response:
refer to 4th floor to fly up high I reply: Quote: refer to the third floor QZJHJXJ response: press can ah, you wrote for reference: typedef int ElemType;//the type of data elements for integer Typedef struct LNode { ElemType data;//data domain Struct LNode * next;//pointer field } LNode * LinkList;//LinkList for pointer to structure LNode type Void MergeList_L (LinkList LA LinkList LB, LinkList & amp; LC)//function definition { LinkList p; P=LC; } //my own definition of LinkList p; //I want how to make p=LC; Int main () { LinkList La=(LinkList) malloc (sizeof (LNode)); LinkList Lb=(LinkList) malloc (sizeof (LNode)); LinkList Lc=(LinkList) malloc (sizeof (LNode)); MergeList_L (La and Lb, Lc); system("pause"); } Friend, I that LC is take address (you can see is & amp; LC), then p is variable of LinkList, should be a pointer variables * p, but LinkList itself and pointer variable, defined as pointer variable p I don't know how to refer to a component in the structure, so I want to ask how can let p=LC Reference: typedef int ElemType;//the type of data elements for integer Typedef struct LNode { ElemType data;//data domain Struct LNode * next;//pointer field } LNode * LinkList;//LinkList for pointer to structure LNode type Void MergeList_L (LinkList LA LinkList LB, LinkList & amp; LC)//function head that define { LinkList p=LC; P - & gt; data=https://bbs.csdn.net/topics/20; P - & gt; Next=NULL; } Int main () { LinkList La=(LinkList) malloc (sizeof (LNode)); LinkList Lb=(LinkList) malloc (sizeof (LNode)); LinkList Lc=(LinkList) malloc (sizeof (LNode)); MergeList_L (La and Lb, Lc); LinkList p=Lc; While (p) { Printf (" % d ", p - & gt; The data); P=p - & gt; Next; } system("pause"); }