快帮我看一下,我的回文哪错了
我想用栈和链表实现回文的检查,但始终有个语法错误,还有算法上好像有点错,请大家帮我一下!!!#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
struct M
{
char*top;
char*base;
int size;
};
struct list
{
char data;
struct list*next;
};
void init(struct M*n);
void push(struct M*m,char c);
void pop(struct M*m,char*e);
void main()
{
struct list*p1,*p2,*head;
struct M sq;
char ch,e;
init(&sq);
head=(struct list*)malloc(sizeof(struct list));
head=NULL;
p2=head;
while((ch=getchar())!='\n')
{
push(&sq,ch);
p1=(struct list*)malloc(sizeof(struct list));
p1->data=ch;
p1->next=p2->next;
p2->next=p1;
p2=p1;
}
p1=head->next;
pop(&sq,&e);
while(p1!=NULL)
{
if(strcmp(e,p1->data)==0) 显示'strcmp' : cannot convert parameter 1 from 'char' to 'const char *',这是什么意思
{ p1=p1->next;
pop(&sq,&e);
}
else {
printf("不是回文\n");
exit(0);
}
}
printf("是回文!\n");
}
void init(struct M*n)
{
n->base=n->top=(char*)malloc(N*sizeof(char));
if(!n->base)
{printf("cant creat!\n");
exit(0);
}
n->top=n->base;
n->size=N;
}
void push(struct M*m,char c)
{
if((m->top-m->base)==m->size)
printf("stack full\n");
else
*m->top++=c;
}
void pop(struct M*m,char*e)
{
if(m->top==m->base)
{
printf("栈空!\n");
exit(0);
}
else
*e=*--m->top;
}
我想用栈和链表实现回文的检查,但始终有个语法错误,还有算法上好像有点错,请大家帮我一下!!!