想用c++进行一个顺序表建立,初始化,插入数据并输出的操作,结果编译不成功。(无法解析外部函数main,函数“int_cdeci invoke_main(void)"(?invoke_main@@YAHXZ)中引用了该符号)
以下为代码
#include<stdio.h>
#include<stdlib.h>
#define MaxSize 20
typedef int ElemType;
typedef struct {
ElemType date[MaxSize];
int length;
}SqList;
void CreatList_Sq(SqListL,ElemType a[],int n)
{
int i;
L = (SqList)malloc(sizeof(SqList));
for ((i = 0); i < n; i++)
L->date[i] = a[i];
L->length=n;
}
void InitList_Sq(SqListL)
{
L = (SqList)malloc(sizeof(SqList));
L->length = 0;
}
bool ListInsert_Sq(SqList*&L, int i, ElemType e) {
int j;
if (i<1 || i>L->length + 1)
return false;
i--;
for (j = L->length; j > i; j--)
L->date[i - 1] = e;
L->length++;
return true;
}
void ListTraverse_Sq(SqList*L)
{
int i;
for (i = 0; i < L->length; i++)
printf("%d", L->date[i]);
printf("\n");
}
截图