C语言数据结构链表尾插法问题!求解释
老是没有结果,求大牛帮忙解释下原因,实在是没搞懂!到底问题出在哪里?
typedef struct LNode{ ElemType date; struct LNode *next;}*LinkList;//Initial LinkListvoid InitL(LinkList &L){ L = (LinkList)malloc(sizeof(LNode));//we just need a RAM directory to told us where the LinkList is. L->next = NULL;}//Create LinkListvoid CreateL(LinkList &L){ int len; //Firstly,we need to known the length of the LinkList. printf("Please input L length:"); scanf("%d", &len); for(int i = 0 ; i < len; i++){ LinkList p = (LinkList)malloc(sizeof(LNode)); //or LinkList p = new LNode(c++) if(!p) printf("Error\n"); printf("Please input LinkList number:"); scanf("%d", &p->date); //tail insert L->next = p; L = p; }}