Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pointer in a function "expected expression before = token"

I try to learn using pointers in functions by "simply" counting a circle. i get the error expected expression before '=' token but cant understand why. saying expected expression before.. is unclear to me, what kind of?

#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);

}
like image 248
muni Avatar asked Dec 19 '22 06:12

muni


2 Answers

#define PI = 3.1415f

should be

#define PI 3.1415f

The macro PI is replaced when used in the code by 3.1415

like image 150
Gopi Avatar answered Jan 09 '23 12:01

Gopi


#define PI = 3.1415f

There should be no = here. Change into

#define PI (3.1415f)
like image 22
timrau Avatar answered Jan 09 '23 10:01

timrau