有一个关于栈的问题,还有就是Tc2.0怎么使用单步跟踪,求大佬教教
typedef struct
{
int x;
int y;
} Postype;
typedef struct
{
int ord;
Postype *seat;
int di;
} SElemType;
typedef struct
{
SElemType *base;
SElemType *top;
int stacksize;
} SqStack;
Status InitStack(SqStack *S)
{
S->base=(SElemType*)malloc(100*sizeof(SElemType));
if(!S->base) exit(OVERFLOW);
S->top=S->base;
S->stacksize=100;
return OK;
}
Status StackEmpty(SqStack S)
{
if(S.base==S.top) return TRUE;
else return FALSE;
}
Status Pop(SqStack *S,SElemType *e)
{
if(S->base==S->top) return ERROR;
*e=*(--S->top);
return OK;
}
Status Push(SqStack *S,SElemType e)
{
if(S->top-S->base>=S->stacksize)
{
S->base=(SElemType*)realloc(S->base,(S->stacksize+STACKINCREMENT)*sizeof(SElemType));
if(!S->base) exit(OVERFLOW);
S->top=S->base+S->stacksize;
S->stacksize+=STACKINCREMENT;
}
*(S->top++)=e;
return OK;
}
我这个结构的堆栈,堆栈元素里面有一个一级指针,主函数里面只声明了一个SElemType类型的e,所以每次Push时,都需要先对e.seat分配空间,不然Pop的e的seat就会出错,请问除了每次分配,还有其他的办法吗?
还有一个问题就是,现在使用的是TC2.0,我只会断点法,请问如何使用单步追踪法,请大佬指教指教!!!