|
程序代码如下:
#include<iostream>
#include<malloc>
#define OK 1
#define OVERFLOW 0
#define INIT_LIST_SIZE 100
typedef int Status;
typedef int ElemType;
typedef struct {
ElemType *elem;
int length;
int listsize;
}Sqlist;
Status Initlist(Sqlist &L)
{
L.elem=(ElemType *)malloc(INIT_LIST_SIZE*sizeof(ElemType);
if(!L.elem) exit(OVERFLOW);
L.length=0;
L.listsize=INIT_LIST_SIZE;
return OK;
}
Status main()
{
Sqlist la;
if(Initlist(la)==OK)
printf("建表成功!");
}
然后编译出现错误:
initlist.c:2:17: error: malloc: 没有那个文件或目录
initlist.c: In function 'Status Initlist(Sqlist&)':
initlist.c:21: error: expected primary-expression before '*' token
initlist.c:21: error: expected primary-expression before ')' token
initlist.c:21: error: expected `;' before 'malloc'
请大家帮帮忙!!看看出了什么问题阿?? |
|