/*棧類型*/
typedef struct Node
{
ElemType data;
struct Node *next;
}Node,*LinkStackPtr;
typedef struct LinkStack
{
LinkStackPtr top;
int count;
}LinkStack,*pLinkStack;
/*初始化棧*/
/*對於空棧來說,棧表原定義的空棧是指頭指針指向空,那麼鏈棧的空就是top為空。*/
Status InitStack(pLinkStack *S)
{
*S = (LinkStack*)malloc(sizeof(LinkStack));
//S = (LinkStackPtr)malloc(sizeof(Node));
if (!(*S))
{
return ERROR;
}
(*S)->count = 0;
(*S)->top = NULL;
return OK;
}