Expected expression before '=' token in C

前端 未结 2 1245
既然无缘
既然无缘 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
    
    0 讨论(0)
  • 2021-01-27 10:55

    You don't need the '=' when you use the define keyword. Including it will include the '=' in the definition.

    #define PI 3.14159265
    
    0 讨论(0)
提交回复
热议问题