tagExpreNode * pExpreNode = NULL;
generateTree( &pExpreNode , pexpresion );
result = c(pExpreNode);
erase(pExpreNode);
}
return result;
};
int main(int argc , char *argv[])
{
/* // tagT t = {0} 可以完成初始化
char c = {0};
typedef struct
{
char c1[100];
char c2[100];
char c3[100];
char c4[100];
char c5[100];
char c6[100];
}
tagT;
memset(c , '0' , 100);
printf(“c=[%s]\n” , c);
//tagT t = {0};
tagT t;
printf(“[%s][%s][%s][%s][%s][%s]\n” , t.c1 , t.c2 , t.c3 , t.c4 , t.c5 , t.c6);
*/
// 计算
//char f[]= “10 1/2/((3-5)*4/(5 2.8)*6/(-7)*(8*9-9))*(-10)”;
//char f[] = “4 ((1 2)*(3 4) 3)/(1 1)”;
//char f[] = “1 2 3 4 6/2”;
char f[] = “-1/2”;
printf(“%s = %f\n” , f , calculate(f));
/* // 结构体中指针的sizeof
typedef struct
{
void *p;
char c ;
}
tagT2;
printf(“hello\n”);
// 取结构体地址,只是一个相加操作,与引用具体数据是两码事。所以,下面代码如果去掉size_t后面的&,会出core,因为引用了NULL->p,
// 而当加上取地址符号时,则没有错误,因为仅仅做了一个相加操作,返回一个地址而已。
printf(“offset(tagT2.p)[%d] offset(tagT2.c)[%d].\n” , (size_t)&(((tagT2*)0)->p) , (size_t)&(((tagT2*)0)->c));
printf(“hello2.\n”);
tagT2 t2;
printf(“sizeof(tagT2.p)[%d] sizeof(tagT2.c)[%d].\n” , sizeof(t2.p) , sizeof(t2.c));
*/
return 0;
};
// end line of file