user-0 提问: 求，，，这个主函数怎么写，其实主要是初始化后我不会往里面给结点变量data赋值，

回复:
user: user-1
content: 最后，注意一下代码风格，函数名，变量名的命名规则要统一，不要一会这个命名规格，一会另一个命名规则，建议加强代码可读性的努力。

user: user-1
content: #include<stdio.h> //#include<malloc.h> #include <stdlib.h>  typedef struct Node{     int data;     struct Node *pre;     struct Node *next; }Node, *NodeList;   #define false (-1) #define true (0)  NodeList CreateList(NodeList L, int length) {     int i, data;     NodeList newnum, tail;     tail = L;      for(i = 0; i < length; i++) {         printf("请输入的结点的数值：");         scanf("%d", &data);          newnum = (NodeList)malloc(sizeof(Node));         if (!newnum) {             fprintf(stderr, "malloc error!\n");             exit(-1);         }         newnum->data = data;          newnum->next = tail->next;         tail->next = newnum;         tail = newnum;     }      return L; }  void InitList(NodeList *L) {     *L = (NodeList)malloc(sizeof(Node));     if(!(*L)) {         fprintf(stderr, "malloc error!\n");         exit(-1);     }      (*L)->next = (*L)->pre = *(L); }  void DestoryList(NodeList *L) {     NodeList q, p;      q = (*L)->next;     while(q != *L) {         p = q->next;         free(q);         q = p;     }     free(*L);     *L = NULL;  } int ClearList(NodeList L) {     NodeList q, p=L->next;     while(q!=NULL)     {         p=q->next;         free(q);         q=p;     }     L->next=L->pre=L; } int JudgeNULL(NodeList L) {     if(L->pre==L&&L->next==L)         return true;     else         return false; } int GetElem(NodeList L,int i,int *e) {     int j=1;     NodeList p=L->next;     while(p!=L&&j<i)     {         p=p->next;         j++;     }     *e=p->data;     if(p==L&&j>i)     {         return false;     }     // return *e;(指针类型不用返回) } int GetLength(NodeList L) {     int length=0;     NodeList p=L->next;     while(p!=L)     {         length++;         p=p->next;     }     return length; } int LocateElem(NodeList L,int e,int (*compare)(int ,int)) {     int j=1;     NodeList p=L->next;     while(p!=L)     {         if(compare(p->data,e))         {             return j;         }         p=p->next;         j++;     } } /*int PreElem(NodeList L,int i)   {   NodeList p;   int j=0;   p=L->next->next;   while(p!=L&&j<i-1)   {   p=p->next;   }   return p->pre->pre->data;   }*/ NodeList GetElemdirection(NodeList L,int i) {     NodeList p;     int j=1;     p=L;//因为最后要返回的是一个p的位置指针,所以也可以是L，故此时不必再对L进行判断     for(j=1;j<=i;j++)     {         p=p->next;     }     return p; } int InsertElem(NodeList L,int i, int data) {     if(i<1||i>GetLength(L))         return false;     NodeList p,newnum;     p=GetElemdirection(L,i-1);     newnum=(NodeList)malloc(sizeof(Node));     newnum->data=data;     newnum->pre=p;     newnum->next=p->next;     p->pre->next=newnum;     p->next=newnum; } int DeleteElem(NodeList L,int i) {     if(i<1||i>GetLength(L))         return false;     NodeList p,prenum;     p=GetElemdirection(L,i);     p=p->next=p->pre;     free(p); } int GetPre(NodeList L,int i) {     if(i<2||i>GetLength(L)+1)         return false;     NodeList p=GetElemdirection(L,i);     if(i==GetLength(L)+2)     {         NodeList s=GetElemdirection(L,i+1);         return s->data;     }     else         return p->pre->data; } int Getnext(NodeList L,int i) {     if(i<1||i>=GetLength(L)+1)         return false;     NodeList p=GetElemdirection(L,i);     return p->next->data; }  void PutHead(NodeList L,int data) {     NodeList p = L;     NodeList newnum;     newnum=(NodeList)malloc(sizeof(Node));     newnum->data=data;     L->next=newnum; }  void output (NodeList phead) {     NodeList p = phead->next;      printf("Show the data list: \n");     while (p != phead) {         printf("%d\t", p->data);         p = p->next;     }     putchar(10); }  int main(void) {     int len;     NodeList phead;      InitList(&phead);     printf("Please input the length of double link:");     scanf("%d", &len);     phead = CreateList(phead, len);     output(phead);      return 0; } 问题还是比较多的，改了初始化双向循环链表头，创建双向链表并赋值； 其他函数没有改，建议你尝试动手改一改；基本的语法错误，要先解决；有返回值，就要加返回值，如果没有必要返回值，那就把函数定义成void类型； 建议在这个基础上继续改，然后有问题继续问吧/