#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define MAXSIZE 100
typedef int Status;
typedef char SElemType;
/定义链表栈/
typedef struct StackNode {
SElemType data;
struct StackNode* next;
}StackNode, *LinkStack;
//初始化链表
Status InitStack(LinkStack S)
{
S = (LinkStack)malloc(sizeof(StackNode));
if (!S)
return OK;
else
{
S = NULL;
return OK;
}
}
//判定栈是否为空
Status StackEmpty(LinkStack S)
{
if (S == NULL)
return TRUE;
else
return FALSE;
}
//入栈
Status Push(LinkStack &S, SElemType &e)
{
StackNode* p;
p = new StackNode;
p->data = e;
p->next = S;
S = p;
return OK;
}
//出栈
Status Pop(LinkStack &S, SElemType e)
{
if (S == NULL)
{
return ERROR;
}
e = S->data;
StackNode* p;
p = S;
S = S->next;
delete p;
return OK;
}
//获取栈顶元素
Status GetTop(LinkStack S, SElemType e)
{
if (S != NULL)
e=S->data;
return OK;
}
请问主函数前面这样写是对的吗?