新人求教,实在找不出错~
#include <stdio.h>#include <malloc.h>
#define NULL 0
struct a
{
int * base;//栈底
int * top;//栈顶
int stacksize;//栈的容量
}* p,stack1;
int * creatlink(int a)
{
p = &stack1;
p->base = p->top = (int *)malloc(a*sizeof(int));
p->stacksize = a;
return (p->base);
}
int main()
{
int c;
int * head = NULL;
scanf("%d",c);
head = creatlink(c);
if(head!=NULL)
printf("初始化成功");
return 0;
}
这个程序在VC上运行会自己终止,想了很多遍 就是找不出错~