数据结构回文问题代码运行问题

代码运行不出结果
只可以输入,输出不了结果
#include
using namespace std;
struct SNode
{
SNode *next;
char data;
};
struct LinkStack
{
int count;//结点个数
SNode *top;//栈顶指针
};//链式栈
void initStack(LinkStack *&s)
{
s = new LinkStack;
s->top = new SNode;
s->top->next = NULL;
s->top = NULL;
s->count = 0;
}//初始化链栈
void push(LinkStack *&s,char e)
{
SNode *m = new SNode;//创建一个新结点
m->data = e;
m->next = s->top;
s->top = m;//栈顶上移
s->count++;//结点个数加一
}//进栈
bool pop(LinkStack *&s, char &t)
{
if (s->top == NULL)
return false;//空栈返回
t = s->top->data;//返回栈顶元素
SNode *n = s->top;//暂存栈顶元素
s->top = s->top->next;//栈顶指针下移
delete n;//释放结点
s->count--;//结点个数减一
return true;
}//出栈并返回栈顶元素
bool Isempty(LinkStack *&s)
{
if (s->top == NULL)
return true;
else
return false;
}
bool gettop(LinkStack *&s, char &i)
{
if (Isempty(s))
return false;
i = s->top->data;
return true;
}
void clear(LinkStack *&s)
{
SNode *p;
while (s->top != NULL)
{
p = s->top;
s->top =s->top->next;
delete p;
}
}
bool palindromejudge(LinkStack *&s,char *str)
{
char *p=str;
char ch;
while (*p)
push(s,*p++);
p = str;
while (!Isempty(s))
{
pop(s, ch);//从栈顶依次出栈
if (ch != *p)
{
clear(s);
return false;//不是回文数
}
p++;
}
return true;//是回文数
}
int main()
{
char str[5];
cout << "请输入字符串";
cin.getline(str, 5);
LinkStack *s;
palindromejudge(s, str);
if (palindromejudge(s, str) == true)
cout <<"是回文" << endl;
else
cout << "不是回文" << endl;
system("pause");
return 0;
}

main函数修改如下:

int main()
{
char str[5];
cout << "请输入字符串";
cin.getline(str, 5);
LinkStack *s = new LinkStack();
palindromejudge(s, str);
if (palindromejudge(s, str) == true)
cout <<"是回文" << endl;
else
cout << "不是回文" << endl;
system("pause");
return 0;
}