函数中的指针"在= token&#34之前的预期表达式;

时间:2015-02-16 09:57:20

标签: c pointers c-preprocessor

我尝试通过“简单地”计算圆圈来学习使用函数中的指针。我收到错误expected expression before '=' token,但无法理解原因。在...之前说出预期的表达方式对我来说还不清楚,是什么样的?

#define PI = 3.1415f

void circle(float *wert) {

    *wert = ( (*wert) * (*wert) * PI );

}

int main(void) {

    float radius;

    printf("radius input: ");
    scanf("%f", &radius);    
    circle(&radius);
    printf("the circle size will be: %f", &radius);

}

2 个答案:

答案 0 :(得分:7)

#define PI = 3.1415f

应该是

#define PI 3.1415f

在3.1415

的代码中使用时,宏PI将被替换

答案 1 :(得分:4)

#define PI = 3.1415f

这里应该没有=。转入

#define PI (3.1415f)
相关问题