I am suppose to be creating a memory map of this program for my class, but when I try to compile it, I get an error:
invalid operands to binary expression ('double *' and 'double *')
I am a student, please do not edit the code to print out memory locations, I need to write that myself.
main()
{
double testd;
int testi;
FILE *fpt;
struct frog {
double *x, y;
}frog;
struct frog turtle, *apple, tv[3];
testi = 2;
apple = &turtle;
apple->x = &testd
*(turtle).x = 7.3; //this is where im getting the error.
(*apple).y = 3.6;
turtle.y = 1.5;
for (testi = 0; testi < 3; testi++)
tv[testi].x = &(tv[(testi+1)%3].y);
*(tv[1].x) = 6.4;
}
You are missing the
;at the end of the previous line.You are not wrong to dereference
*(turtle).xinstead of*(turtle.x). The.operator has higher precedence than the*operator, meaning those two statements are equivalent and you don’t even need parentheses: you could just do*turtle.x.Check out this site for precedence ordering.