首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

请帮小弟我看看这段程序里的typedef哪错了,多谢

2012-02-19 
请帮我看看这段程序里的typedef哪错了,谢谢#includestdio.h#includestdlib.h#defineLIST_INIT_SIZE100

请帮我看看这段程序里的typedef哪错了,谢谢
#include   <stdio.h>
#include   <stdlib.h>
#define   LIST_INIT_SIZE   100
#define   LISTINCREMENT   10
struct   list  
{   int   *elem;
    int   length;
    int   listsize;
    };
typedef   struct   list   *sqlist;  
int   InitList(sqlist   L)
{   L-> elem=(int   *)malloc(LIST_INIT_SIZE*sizeof(int));
    if(!L-> elem)exit(0);
    L-> length=0;
    L-> listsize=LIST_INIT_SIZE;
    return   1;
    }
int   InputToList(sqlist   L,int   len)
{   int   i;
    for(i=0;i <len;i++)
scanf( "%d ",L-> elem[i]);
    L-> length=len;
    return   1;
    }
void   ShowList(sqlist   L)
{   int   i;
    printf( "the   elements   of   the   list   are:\n ");
    for(i=0;i <L-> length;i++)
printf( "%3d ",L-> elem[i]);
    printf( "\n ");
    }
main()
{   int   La_len,Lb_len;
    printf( "please   input   the   length   of   La: ");
    scanf( "%d ",&La_len);
    printf( "\n ");
    printf( "please   input   the   length   of   Lb: ");
    scanf( "%d ",&Lb_len);
    printf( "\n ");
    sqlist   La,Lb;
    InitList(La);
    InitList(Lb);
    printf( "input   elements   to   La\n ");
    InputToList(La,La_len);
    printf( "\ninput   elements   to   Lb\n ");
    InputToList(Lb,Lb_len);
    ShowList(La);
    ShowList(Lb);
    getchar();
    }
想写一段线性表的初始化和显式的代码,可是用VC6.0编译的时候总出现以下错误:
:\tc\source\algorithm2_1.c(40)   :   error   C2275:   'sqlist '   :   illegal   use   of   this   type   as   an   expression
                C:\tc\source\algorithm2_1.c(10)   :   see   declaration   of   'sqlist '
C:\tc\source\algorithm2_1.c(40)   :   error   C2146:   syntax   error   :   missing   '; '   before   identifier   'La '
C:\tc\source\algorithm2_1.c(40)   :   error   C2065:   'La '   :   undeclared   identifier
C:\tc\source\algorithm2_1.c(40)   :   error   C2065:   'Lb '   :   undeclared   identifier
C:\tc\source\algorithm2_1.c(41)   :   warning   C4047:   'function '   :   'struct   list   * '   differs   in   levels   of   indirection   from   'int   '
C:\tc\source\algorithm2_1.c(41)   :   warning   C4024:   'InitList '   :   different   types   for   formal   and   actual   parameter   1
C:\tc\source\algorithm2_1.c(42)   :   warning   C4047:   'function '   :   'struct   list   * '   differs   in   levels   of   indirection   from   'int   '


C:\tc\source\algorithm2_1.c(42)   :   warning   C4024:   'InitList '   :   different   types   for   formal   and   actual   parameter   1
C:\tc\source\algorithm2_1.c(44)   :   warning   C4047:   'function '   :   'struct   list   * '   differs   in   levels   of   indirection   from   'int   '
C:\tc\source\algorithm2_1.c(44)   :   warning   C4024:   'InputToList '   :   different   types   for   formal   and   actual   parameter   1
C:\tc\source\algorithm2_1.c(46)   :   warning   C4047:   'function '   :   'struct   list   * '   differs   in   levels   of   indirection   from   'int   '

用Tc2.0编译也出现相似的错误,c语言用的太少,实在检查不出哪里出错,可笑之处还望见谅。请各位不吝赐教,给予宝贵提示,感激不尽。
C:\tc\source\algorithm2_1.c(46)   :   warning   C4024:   'InputToList '   :   different   types   for   formal   and   actual   parameter   1
C:\tc\source\algorithm2_1.c(47)   :   warning   C4047:   'function '   :   'struct   list   * '   differs   in   levels   of   indirection   from   'int   '
C:\tc\source\algorithm2_1.c(47)   :   warning   C4024:   'ShowList '   :   different   types   for   formal   and   actual   parameter   1
C:\tc\source\algorithm2_1.c(48)   :   warning   C4047:   'function '   :   'struct   list   * '   differs   in   levels   of   indirection   from   'int   '
C:\tc\source\algorithm2_1.c(48)   :   warning   C4024:   'ShowList '   :   different   types   for   formal   and   actual   parameter   1
Error   executing   cl.exe.

algorithm2_1.obj   -   4   error(s),   12   warning(s)


[解决办法]
sqlist La,Lb;、、貌似未初始化的指针

热点排行