这是哪里出错了?
程序代码:
#include <stdio.h> #include <stdlib.h> #include <time.h> #define ERROR 5 #define OK 5 //typedef int ElemType; #define ElemType int typedef struct Node { ElemType data; //Êý¾ÝÓò struct Node *next; //Ö¸ÕëÓò }Node ,*LinkList; int CreateListHead(LinkList *L, int n) { LinkList p,r; int i=1; srand(time(0)); //初始化随机种子 (*L) = (LinkList)malloc(sizeof(struct Node)); //先建立一个带头结点的单链表 if((*L) == NULL) { fprintf(stderr, "malloc() error.\n"); return ERROR; } (*L)->next = NULL; r=*L; //尾部结点 for(i=0; i<n; i++) { p=(Node *) malloc(sizeof(Node)); p->data=rand()%100+1; r->next =p; r=p; } r->next = NULL; //表示当前链表结束 return OK; } int ClearList(LinkList *L) { LinkList p,q; p=(*L)->next; while(p) { q=p->next; free(p); p=q; } (*L)->next=NULL; return OK; } int printList(LinkList L) { LinkList p; p = L->next; if(p == NULL) { printf("链表为空.\n"); return ERROR; } while(p) { printf("%d ", p->data); p = p->next; } printf("\n"); return OK; } int main() { LinkList L; printf("Hello world!\n"); CreateListHead(&L,6); printList(L); return 0; }菜鸟一只,怎么return OK 或者return ERROR改成下面都可以正确返回呀?