Expected expression before '=' token in C

前端 未结 2 1249
既然无缘
既然无缘 2021-01-27 10:06

Though the pre processor assigns i = 3.14159265. When i compile it, gives an error saying expected an expression before \'=\' token what and why is that ?

#incl         


        
2条回答
  •  天涯浪人
    2021-01-27 10:54

    #define PI = 3.14159265
    

    defines PI to be = 3.14159265 literally including the equals sign. Thus i = PI; is the same as:

    i = = 3.14159265;
    

    which clearly won't compile. To fix it, remove the = from your definition of PI:

    #define PI 3.14159265
    

提交回复
热议问题