【发布时间】:2016-06-04 10:32:48
【问题描述】:
基本上,我有一个这样定义的结构:
struct D_Array
{
int Capacity;
int Cur_Size;
struct Student* List;
};
现在,在创建结构之后;
struct D_Array* T_Array;
if (T_Array = malloc(sizeof(struct D_Array)) == NULL)
{
printf("There has been a problem with memory allocation. Exiting the program.");
exit (21);
}
我在此结构中创建学生列表时遇到问题。我需要列表是一个指针数组,因为我应该制作某种 ADT 程序,所以我试图让它像这样:
T_Array->Capacity = 10;
T_Array->Cur_Size = 0;
T_Array->List[10]= (struct Student*) malloc(sizeof (struct Student*));
无论我如何尝试更改它,我都会遇到同样的错误: 从“struct Student *”类型分配给“struct Student”类型时不兼容的类型|
我正在尝试创建一个可以执行类似操作的数组;
T_Array->List[1]=Student_Pointer;
谢谢!
【问题讨论】:
标签: c arrays pointers struct abstract-data-type