c语言,程序中函数没被调用。


#include<malloc.h>

#include<string.h>

#include<stdlib.h>

#define OK 0

#define Err_Memory -1

#define Err_InvalidParam -2

#define Err_Overflow -3

#define Err_IllegalPos -4

#define Err_NoResult -5

typedef char *ElemType ;

typedef struct node{

        ElemType data;

        struct node *next;

        }ListNode,*LinkList;

        typedef int Status;
Status InitList (LinkList L)
{
       if (!L) return Err_InvalidParam ;
       L->next=NULL;
       return OK;
}
Status CreateCollection (LinkList C)
{
       int count=1;
       ListNode *s,*p;
       ElemType e;
       if (InitList!=OK) return Err_NoResult ;
       p=C;
       while (1)
       {
             s=(ListNode *)malloc(sizeof(ListNode));
             if (!s) return Err_Memory;
             e=(ElemType)malloc(11*sizeof(char));
             if (!e) return Err_Memory;
             printf("请输入第%d个元素:",count++);
             gets(e);
             if (strcmp(e,"#")==0) break ;
             if (LocataList(e,C)==0)
             {
                                    if (InsertList(p,1,e)!=OK) return Err_NoResult ;
                                    p=p->next;
             }
       }
       return OK;
}
int LocateList (ElemType e,LinkList L)
{
    int i=1;
    ListNode *p;
    if (!L) return Err_InvalidParam ;
    p=L->next;
    while (p&&strcmp (p->data,e)!=0)
    {
          i++;
          p=p->next;
    }
    if (!p) return 0;
    return i;
}
Status InsertList (LinkList L,int i,ElemType e)
{
       ListNode *p,*s;
       int k=1;
       if (!L) return Err_InvalidParam ;
       p=L;
       while (k<i&&p)
       {
             k++;
             p=p->next;
       }
       if (k>i||!p) return Err_IllegalPos;
       s=(ListNode *)malloc(sizeof(ListNode));
       if (!s) return Err_Memory;
       s->data=e;
       s->next=p->next;
       p->next=s;
       return OK;
}
int main()
{
     LinkList A,B,C;
     ElemType s;
     A=(ListNode *)malloc(sizeof(ListNode));
     B=(ListNode *)malloc(sizeof(ListNode));
     C=(ListNode *)malloc(sizeof(ListNode));
     printf("请输入集合A的元素(输入#结束):\n");
     //scanf("%s",A);
     if (CreateCollection(A)!=OK) 
     { printf("集合A创建错误!"); getch();return ;}

图片说明

请问一下,为什么这里,CreateCollection 函数没有被调用呢?
初学数据结构。
补贴了Insert 和Locate 函数。

参考这篇文字的链表 http://blog.csdn.net/cabing2005/article/details/52497156

int LocateList (ElemType e,LinkList L)
{
int i=1;
ListNode *p;
if (!L) return Err_InvalidParam ;
p=L->next;
while (p&&strcmp (p->data,e)!=0)
{
i++;
p=p->next;
}
if (!p) return 0;
return i;
}
Status InsertList (LinkList L,int i,ElemType e)
{
ListNode *p,*s;
int k=1;
if (!L) return Err_InvalidParam ;
p=L;
while (k {
k++;
p=p->next;
}
if (k>i||!p) return Err_IllegalPos;
s=(ListNode *)malloc(sizeof(ListNode));
if (!s) return Err_Memory;
s->data=e;
s->next=p->next;
p->next=s;
return OK;
}

你把LocataList()和InsertList()函数也贴出来

如果你上传的代码跟图里面的是一样的话,先把它改了,再试试
图片说明