问题描述
|
我的C程序具有这样的堆栈类型定义:
typedef struct {
char T[MaxEl+1][MAX_CHAR];
address TOP;
boolean alive;//ignore this
} Stack;
并创建一个函数:
void expandP(Stack stack[],int i,char input[]) {//variable stack is array of Stack
..
Stack temp;
CreateEmpty(&temp);
..
copyStack(&temp,stack[i]);
}
void CreateEmpty(Stack *S) {
Top(*S) = Nil;
isAlive(*S) = false;
}
void copyStack(Stack* out,Stack in) {
}
运行时给出错误分段错误,编译时不给出警告
解决方法
使ѭ2成为指针
void copyStack(Stack* out,const Stack *in) {
然后这样称呼它:
copyStack(&temp,&stack[i]);