结构体数组申请空间的问题
代码如下#include"stdio.h"
#define maxsize 8
#include"malloc.h"
typedef int List;
typedef int position;
typedef struct array
{
int date;
position next;
}linkedlist;
linkedlist cursorspace[maxsize];
void initializer()//想作为全局变量
{
int i;
for(i=0;i<maxsize;i++)
{
cursorspace[i]=(linkedlist)malloc(sizeof(linkedlist));//为什么不能申请成功啊?
cursorspace[i].next=i+1;
cursorspace[i].date=0;
}
}
main()
{
position i;
void initializer();
for(i=0;i<maxsize;i++)
{
printf("%d ",cursorspace[i].next);
}
}
要怎么该才能申请成功啊 ?新手求解啊,谢谢啦