开发者

empty function but segmentation fault in function parameter

my C program has type definition of a stack like this :

typedef struct {
    char T[MaxEl+1][MAX_CHAR];
    address TOP;
    boolean alive;//ignore this
} Stack;

and create a function:

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) {

}

it开发者_如何转开发 gives error segmentation fault when running and no warning when compile


Make Stack in a pointer

void copyStack(Stack* out, const Stack *in) {

And then call it like so:

copyStack(&temp,&stack[i]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜