首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

请问一个 构造线性表的有关问题 菜鸟:)

2012-03-03 
请教一个 构造线性表的问题 初学者:)#include stdio.h#include malloc.h#include conio.h#defineERR

请教一个 构造线性表的问题 初学者:)
#include <stdio.h>
#include <malloc.h>
#include <conio.h>

#define   ERROR   0
#define   OK   1
#define   OVERFLOW   -1
#define   LIST_INIT_SIZE   20
#define   LISTINCRMENT   10
typedef   int   status;

struct   STU{
      char   name[20];
      char   stuno[10];
      int   age;
      int   score;
}stu[50];
typedef   struct   STU   ElemType;

struct   LIST
{
    ElemType   *elem;
    int   length;
    int   listsize;
}

typedef   struct   LIST   sqList;

status   InitList_sq(sqList   *L)
{
    L-> elem=(ElemType   *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
    if(!L-> elem)   exit(OVERFLOW);
    L-> length=0;
    L-> listsize=LIST_INIT_SIZE;
    return   OK;
}
  status   ListLength(sqList   *L)
{
  return   L-> length;
}

    main()
{
    sqList   La;
    int   length;
    status   InitList_sq(&La);
    length=status   ListLength(&La);
    printf( "\n   La.length=   ",La.length);
    getchar();

}


    总是通不过   编译。    
  他说   too   many   types   in   declaration
      (第一个错)
  一共5个   错误。        
谢谢。

[解决办法]
struct LIST {
...
};

InitList_sq(&La);
length=ListLength(&La);

热点排行