|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <stdio.h>
- #include <string.h>
- #define MAXSIZE 50
- typedef struct student{
-
- char sno[4];
- char name[8];
- int age;
- float enscore;
- }STUD;
- typedef struct SeqList{ //顺序表结构体定义
- STUD stu[MAXSIZE];
- int len;
- }List;
- List* Init_StuList(){ //创建空表
- List *p;
- p = (List*)malloc(sizeof(List)); ------》这里报错了
- p->len = 0;
- return p;
- }
- int Locate_List(List l,STUD n){ //定位查找
- int i = 1;
- if(l.len = 0){
- return 0;
- }
- else{
- l.stu[0] = n; //为for循环找不到返回0提供条件
- for(i = l.len; l.stu[i].age!=n.age && l.stu[i].enscore!=n.enscore && !strcmp(l.stu[i].name, n.name) &&!strcmp(l.stu[i].sno, n.sno) ;i--);
- return i;
- }
- }
- int main(){
- Init_SeqList();
- return 0;
复制代码
警告,对malloc()函数没有明确的定义 malloc()函数在头文件stdlib.h下
|
|