1这里总出现CreatList_sq总出现红色波浪线,已在main函数里面声明了,仍然有红波浪线。而且下方n和L也是如此,
2鼠标指到该处,显示"存在正文时不允许未命名的原型参数"
3我想函数已经声明和定义了,为什么会出现这样的情况。
#include<stdio.h>
#define MaxSize 60
typedef int ElemType;
typedef struct {
ElemType data[MaxSize];
int length;
}SqList;
void CreatList_Sq(SqList *L, ElemType a[], int n) {
int i;
L = (SqList*)malloc(sizeof(SqList));
for (i = 0; i < n; i++) {
L->data[i] = a[i];
}
L->length = n;
}
int main() {
void CreatList_Sq(SqList *L, ElemType a[], int n);
void InitList_Sq(SqList * L);
int LocateElem_Sq(SqList * L, ElemType e);
SqList* L;
int num, i;
int n;
InitList_Sq(L);
printf("请逐一输入5个数:\n");
for (i = 0; i < 5; i++) {
scanf_s("%d", &L->data[i].data);
L->length++;
}
printf("查找值:");
scanf_s("%d", &num);
n=LocateElem_Sq(L, num);
printf("%d", n);
}
void InitList_Sq(SqList *L) {
L = (SqList*)malloc(sizeof(SqList));
L->length = 0;
}
int LocateElem_Sq(SqList* L, ElemType e)
{
int i = 0;
while (i < L->length && L->data[i] != e) {
i++;
}
if (i < L->length)
return i + 1;
else
return 0;
}