100分问问题

GR 2003-11-27 10:57:34

#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10

typedef char ElemType;



typedef struct {
ElemType *elem;
int lenth;
int listsize;
}SqlList,*pSqlList;


pSqlList InitList(pSqlList L)
{
L->elem = (ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L->elem)
return 0;


L->lenth = 0;
L->listsize = LIST_INIT_SIZE;
return L;
}



void main()
{

pSqlList LA = InitList(LA);
}

各位.local variable 'LA' used without having been initialized
错误是这样的.

...全文
20 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ryyy 2003-11-27
  • 打赏
  • 举报
回复
void InitList(pSqlList *L)
{
L->elem = (ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L->elem)
return 0;


L->lenth = 0;
L->listsize = LIST_INIT_SIZE;
return L;
}



void main()
{

pSqlList LA;
InitList(&LA);
}


改成这样试试
bohut 2003-11-27
  • 打赏
  • 举报
回复
#include <string>

#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10

typedef char ElemType;

typedef struct
{
ElemType *elem;
int lenth;
int listsize;
}SqlList;


SqlList* InitList(SqlList *L)
{
if(!L->elem)
return 0;

L->lenth = 0;
L->listsize = LIST_INIT_SIZE;
return L;
}



void main()
{
SqlList *LA ;
LA = (SqlList*)malloc(LIST_INIT_SIZE*sizeof(SqlList));
InitList(LA);
}
inline 2003-11-27
  • 打赏
  • 举报
回复
#include<stdlib.h>

#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10

typedef char ElemType;



typedef struct {
ElemType *elem;
int lenth;
int listsize;
}SqlList,*pSqlList;


pSqlList InitList(pSqlList L)
{
L->elem = (ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L->elem)
return 0;
L->lenth = 0; //如果指针未初始化则地址非法引用
L->listsize = LIST_INIT_SIZE; //同上
return L;
}



void main()
{
pSqlList LA = new SqlList;
LA= InitList(LA);
delete LA;
}
lishifeng 2003-11-27
  • 打赏
  • 举报
回复
请问你的指针LA指向哪里?

改了一下

void main()
{
SqlList A;

pSqlList LA = InitList(&A);
}

69,368

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧