表达式求值(Expression Evaluation)
编写程序对表达式求值。
Enter an expression: 1+2.5*3
Value of expression: 10.5
表达式中的操作数是浮点数,运算符是+、-、*和/。表达式从左向右求值(所有运算符的优先级都⼀样)。
下面这个是我写的
#include <stdio.h>
int main() {
char a;
float b;
printf("Enter an expression:");
while (sizeof(a=getchar())==2)
{ b=(float)a;
a=(char)b;}
printf("Value of expression:%f",b);
return 0;}
他老是报错说:warning: ‘b’ is used uninitialized in this function
为什么啊,getchar不是一个一个输入的嘛?