请大家帮帮我!!!一个程序引发的问题!!
#include<stdio.h>#include<stdlib.h>
#define SIZE 100
struct brack
{
char*base;
char*top;
int stacksize;
};
void init(struct brack*m);
void push(struct brack*m,char c);
int pop(struct brack*m,char*e);
void main()
{
char ch,t;
int flag;
struct brack sq;
init(&sq);
while((ch=getchar())!='\n')
{
if(ch=='('||ch=='['||ch=='{')
push(&sq,ch);
else if(ch==')'||ch==']'||ch=='}')
{
flag=pop(&sq,&t);
if(flag==0)
break;
else if((ch==')')&&(t=='('))
flag=1;
else if((ch==']')&&(t=='['))
flag=1;
else if((ch=='}')&&(t=='{'))
flag=1;
else {
flag=0;
break;
}
}
}
if(flag==1)
printf("match!!!\n");
else
printf("not match!!!\n");
}
void init(struct brack*m)
{
m->base=m->top=(struct brack*)malloc(SIZE*sizeof(struct brack)); 就是这一行: : cannot convert from 'struct brack *' to 'char *'
if(!m->base)
{printf("cant creat!\n");
exit(0);
}
m->top=m->base;
m->stacksize=SIZE;
}
void push(struct brack*m,char c)
{
if((m->top-m->base)==m->stacksize)
printf("stack full\n");
else
*m->top++=c;
}
int pop(struct brack*m,char*e)
{
int FLAG;
if(m->top==m->base)
FLAG=0;
else{
*e=*--m->top;
FLAG=1;
}
return FLAG;
}
1.为什么这个程序在TC能运行,到了VC++就显示 : cannot convert from 'struct brack *' to 'char *',这是为什么???
2.我最初都使用的"m.top,m.base",后来改成了“m->top,m->base''才能用,我不太清楚他们的区别
3.void init(struct brack*m);
void push(struct brack*m,char c);
int pop(struct brack*m,char*e);
这些*号,能换成&吗,我不太清楚他们的区别
请高手救我!!!