为什么报 'fuhao' : 'struct' type redefinition这个错误?

来源:百度知道 编辑:UC知道 时间:2024/05/24 00:58:19
#include <stdlib.h>
#include <malloc.h>

#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define TRUE 1
#define FLASE 0
#define SIZE 100
#define ZSIZE 10

typedef struct Snum
{
double * top;
double * base;
int stacksize;
}Snum;

typedef struct fuhao
{
char * top;
char * base;
int stacksize;
}Sfuhao;

int InitSfuhao(Sfuhao * S);
int InitSnum(Snum * S);
int empty(Sfuhao * S);
int GetTopf(Sfuhao * S,char * e);
int GetTopd(Snum * S,double * e);
int Pushf(Sfuhao * S,char e);
int Pushd(Snum * S,double e);
int Popf(Sfuhao * S,char * e);
int Popd(Snum * S,double * e);
int GetTopf(Sfuhao * S,char * e)
{
if(S->base == S->top)
return ERROR;
* e = * (S->top - 1);
return OK;
}

int GetTopd(Snum * S,double * e)
{
if(S->base =

贴完整可以吗?
------------
在没有给出main函数的情况下,无法编译。但目前至少有两处错误, InitSfuhao和InitSnum返回类型应设为void

没有粘贴完的:
int InitSfuhao(Sfuhao * S)
{
S->base = (char *)malloc(SIZE * sizeof(char));
if(!S->base)
exit(OVERFLOW);
S->base = S->top;
S->stacksize = SIZE;
}

int InitSnum(Snum * S)
{
S->base = (double *)malloc(SIZE * sizeof(double));
if(!S->base)
exit(OVERFLOW);
S->base = S->top;
S->stacksize = SIZE;
}

int Pushf(Sfuhao * S,char e)
{
if(S->top - S->base >= S->stacksize)
{
S->base = (char *)realloc(S->base,ZSIZE * sizeof(char));
if(!S->base)
exit(OVERFLOW);
S->top = S->base + S->stacksize;
S->stacksize += ZSIZE;
}
* S->top++ = e;
return OK;
}

int Pushd(Snum * S,double e)
{
if(S-&g