运行后说error C2275:'list' :illegal use of this type as an expression#include#include #define max 100typedef struct{\x09int *data;\x09int length;}list;init(list &l){\x09l.data=(int*) malloc (max*sizeof (int));\x09if(!l.data)return 0;\x09l.length=
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 01:38:40
运行后说error C2275:'list' :illegal use of this type as an expression#include#include #define max 100typedef struct{\x09int *data;\x09int length;}list;init(list &l){\x09l.data=(int*) malloc (max*sizeof (int));\x09if(!l.data)return 0;\x09l.length=
运行后说error C2275:'list' :illegal use of this type as an expression
#include
#include
#define max 100
typedef struct{
\x09int *data;
\x09int length;
}list;
init(list &l)
{
\x09l.data=(int*) malloc (max*sizeof (int));
\x09if(!l.data)return 0;
\x09l.length=0;
\x09return 1;
}
insert(list &l,int p,int e)
{
\x09int i;
\x09if(pl.length+1)
\x09\x09return 0;
\x09for (i=l.length;i>=p;--i)
\x09\x09l.data[i+1]=l.data[i];
\x09l.data[p]=e;
\x09++(l.length);
\x09return 1;
}
void main ()
{
\x09list &l;int i;
init(list &l);
printf("你要输入多少个数据/n");
scanf ("%d",&l.length);
printf("输入元素中/n");
for(i=1;i
运行后说error C2275:'list' :illegal use of this type as an expression#include#include #define max 100typedef struct{\x09int *data;\x09int length;}list;init(list &l){\x09l.data=(int*) malloc (max*sizeof (int));\x09if(!l.data)return 0;\x09l.length=
init(list &l);调用函数时,参数前不用传参数类型,用init(&l)即可