| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 795 人关注过本帖
标题:[求助]创造线性表时候的 elem指针问题
只看楼主 加入收藏
mgp1030
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-3-27
收藏
 问题点数:0 回复次数:0 
[求助]创造线性表时候的 elem指针问题

/*创建一个顺序表*/

#include <stdio.h>
#include <stdlib.h>

typedef int Status;
typedef int ElemType;

#define OK 1;
#define ERROR -1;
#define OVERFLOW -2;
#define LIST_INIT_SIZE 100;
#define LISTINCREMENT 10;

typedef struct { //存储结构
ElemType *elem;
int length;
int listsize;
}Sqlist;

Status InitList_Sq(Sqlist *L){ //创建空的线性表

(*L).elem = (ElemType*)malloc(LIST_INIT_SIZE * sizeof(ElemType));

if( !((*L).elem ))
return OVERFLOW;

(*L).length = 0;
(*L).listsize = LIST_INIT_SIZE;
return OK;
}

void main()
{
Sqlist L;
int i;

if( InitList_Sq(&L) == OVERFLOW) printf("ERROR");

else
{
printf("please input the L number:"); //赋值
for(i = 0; i < L.listsize; i++)
{
scanf("%d", &L.elem[i]); L.length++;

/搞不懂,这里为什么是L.elem[i],为什么不是L.elem,elem是一个指针,但没定义它是一个数组指针啊。*/

}
printf("The L is:");
for (i = 0; i <L.listsize; i++)
printf("%d ", L.elem[i]);
}
}


调试问题:
Compiling...
12345.C
d:\tc20\12345.c(21) : error C2143: syntax error : missing ')' before ';'
d:\tc20\12345.c(21) : error C2059: syntax error : ')'
d:\tc20\12345.c(21) : error C2100: illegal indirection
d:\tc20\12345.c(36) : error C2143: syntax error : missing ')' before ';'
d:\tc20\12345.c(36) : error C2059: syntax error : ')'
d:\tc20\12345.c(38) : error C2181: illegal else without matching if
执行 cl.exe 时出错.

12345.exe - 1 error(s), 0 warning(s)

找了一个晚上没发现问题在哪,请帮忙指点。。。。。。。。。。。。。。。

搜索更多相关主题的帖子: 线性 elem 指针 
2006-04-07 12:42
快速回复:[求助]创造线性表时候的 elem指针问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022597 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved