如题:
要实现一个线性表的结构,但是在一开始初始化赋值时出现了问题。
```# include
include
include
using namespace std;
#define INIT_SIZE 1000
#define INCREMENT 1000
typedef struct {
string num;
string name;
float score;
}student , *student_l;
typedef struct {
student_l Student_List;
int length;
int listsize;
}List;
int Initial_List(List &L, int n =0 ) //初始化表格,分配空间
{
L.Student_List = (student_l)malloc(INIT_SIZE * sizeof(student));
if (!L.Student_List) return -1;
string student_name;
string student_num;
float student_score = 0;
/*for (int i = 0; i < n; i++)
{
cin >> student_num >> student_name >> student_score;
L.Student_List[i].name = student_name;
L.Student_List[i].num = student_num;
L.Student_List[i].score = student_score;
}*/
L.length = n;
L.listsize = INIT_SIZE;
return 0;
}
int main()
{
int student_number = 0;
List student_List;
cin >> student_number;
Initial_List(student_List, student_number);
return 0;
system("pause");
}