edit函数出问题,读入字符的循环进不去
#include "stdio.h"#include "stdlib.h"
#define NULL 0
#define TRUE 1
#define MAXSIZE 100
typedef char datatype;
typedef struct
{
datatype stack[MAXSIZE];
int top;
}seqstack;
seqstack *s;
void INITSTACK(seqstack *s)
{
s->top=-1;
}
int EMPTY(seqstack *s)
{
if(s->top <0)
return TRUE;
else return NULL;
}
seqstack *push(seqstack *s,datatype x)
{
if(s->top ==MAXSIZE-1)
{ printf("the stack is full\n");
return NULL;
}
else
{
s->top++;
s->stack[s->top]=x;
}
return s;
}
datatype pop(seqstack *s)
{
datatype x;
if(EMPTY(s))
{
printf("the stack is empty\n");
return NULL;
}
else
{
x=s->stack[s->top];
s->top--;
}
return x;
}
void edit()
{
char c,name[80];
int k=0;
printf("input char as * to end\n");
c=getchar();
name[k++]=c; printf("%d\n",100);
while(c!='*')
{
if(c=='#')
pop(s);
if(c=='@')
INITSTACK(s);
else push(s,c);
c=getchar();
name[k++]=c;
}
name[k++]='\0';
k=0;
printf("you input char is:\n");
while(name[k]!='\0')
printf("%c ",name[k++]);
}
void main()
{ s=(seqstack *)malloc(sizeof(seqstack));
char c;
edit();
printf("output char:\n");
while(EMPTY==0)
{
c=pop(s);
printf("%c ",c);
}
printf("\n\n");
getchar();
}