新人求助,关于数组问题
http://zhidao.baidu.com/question/410344599.html
请好心人帮忙解决一下
[解决办法]
.h
extern struct S s[1024*1024]
struct S
{
int a;
};
.c
struct S s[1024*1024];
int main()
{
...
}
[解决办法]
#include <stdio.h>#include <malloc.h>#define LEN sizeof(struct s)struct s{ int num; struct s * point;};void main(){ struct s *head,*p1,*p2;//定义三个结构体指针 int n,i; printf("输入要开辟的空间数!\n"); scanf("%d",&n); p1=p2=(struct s *)malloc(LEN); for(i=1;i<=n;i++) { if(i==1) head=p1; else p2=p1; p1=(struct s *)malloc(LEN); p2->point=p1; } p2->point=0;}