我必须检查s1和s2的顶牌。s1 是一摞牌,s2 也是。我已经拥有的 stack_top 函数如下:
/* Retrive data from the top of the stack */
node_data stack_top(stack *s){
if(!stack_empty(s)){ /* If the stack is not empty */
return (s->top->data); /* Return the data */
}
else{ /* Otherwise there is an error */
cardlist_error("stack_top called on empty stack");
}
}
我有
while (strcmp (stack_top(s1), stack_top(s2)) ==0 )
//then do the following..
但我有一个segmentation fault
,我应该如何比较它们 2?