当前位置: 代码迷 >> C语言 >> 初学者 程序中的错误 高手帮忙看下
  详细解决方案

初学者 程序中的错误 高手帮忙看下

热度:612   发布时间:2008-06-27 22:29:54.0
初学者 程序中的错误 高手帮忙看下
#include "stdio.h"
#include "stdlib.h"
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int Status;
typedef int Elemtype;
typedef struct
{
        Elemtype *elem;
        int length;
        int listsize;

}sqlist;

Status Inslist(sqlist *L,int i)
{int m,*p,*q;
if(i>L.length||i<1)
return 0;
printf("请输入想要插入的元素:");
scanf("%d\n ",&m);
q=&(L.elem[i-1]);
for(p=&(L.elem[L.length-1]);p>=q;--p)
*(p+1)=*p;
*q=m;
++L.length;
printf("新表的元:");
for(m=0;m<L.length;++m)
printf("%d  ",L.elem[m]);
printf("表长为:%d,容量为:%d",L.length,L.listsize);
return 1;
}
void main()
{int i,m,n;
sqlist *L;
L.elem=(Elemtype*)malloc(LIST_INIT_SIZE*sizeof(Elemtype));
if(!L.elem)exit(OVERFLOW);
L.length=0;
L.listsize=LIST_INIT_SIZE;
printf("请输入元素个数:");
scanf("%d",&m);
if(m>L.listsize)
return 0;
L.length=m;
printf("请输入元素:\n");
for(i=1;i<=m;++i)
{scanf("%d ",&L.elem);
++L.elem;
}
printf("请输入要插入的元素位置:");
scanf("%d",&m);
Inslist(L,m);
}
我初步编的就有许多同样的错误



Text1.c
C:\Documents and Settings\liujiesmart\桌面\Text1.c(20) : error C2231: '.length' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(24) : error C2231: '.elem' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(25) : error C2231: '.elem' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(25) : error C2231: '.length' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(28) : error C2231: '.length' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(30) : error C2231: '.length' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(31) : error C2231: '.elem' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(32) : error C2231: '.length' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(32) : error C2231: '.listsize' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(38) : error C2231: '.elem' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(39) : error C2231: '.elem' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(40) : error C2231: '.length' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(41) : error C2231: '.listsize' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(44) : error C2231: '.listsize' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(45) : warning C4098: 'main' : 'void' function returning a value
C:\Documents and Settings\liujiesmart\桌面\Text1.c(46) : error C2231: '.length' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(49) : error C2231: '.elem' : left operand points to 'struct', use '->'
C:\Documents and Settings\liujiesmart\桌面\Text1.c(50) : error C2231: '.elem' : left operand points to 'struct', use '->'
执行 cl.exe 时出错.
搜索更多相关的解决方案: int  define  

----------------解决方案--------------------------------------------------------
use '->'
----------------解决方案--------------------------------------------------------
#include "stdio.h"
#include "stdlib.h"
不是“”应该是<>
----------------解决方案--------------------------------------------------------
感觉LZ的代码好像就是伪代码吧。

数据结构书上的?
----------------解决方案--------------------------------------------------------
  相关解决方案