Use some quick help

This is a discussion on Use some quick help within the C Programming forums, part of the General Programming Boards category; Hello again. I don't know what is wrong with the following equation, but I keep getting this error message. Error ...

1. Use some quick help

Hello again. I don't know what is wrong with the following equation, but I keep getting this error message.

Error 4 error C2676: binary '-' : 'Vector' does not define this operator or a conversion to a type acceptable to the predefined operator

Code:
`F*=G*((bodies[i].m*bodies[i++].m)/(sqrt((bodies[i].r.x-bodies[i++].r.x)*(bodies[i++].r.x-bodies[i].r.x)+(bodies[i++].r.y-bodies[i].r.y)*(bodies[i++].r.y-bodies[i].r.y))*sqrt((bodies[i++].r.x-bodies[i].r.x)*(bodies[i++].r.x-bodies[i].r.x)+(bodies[i++].r.y-bodies[i].r.y)*(bodies[i++].r.y-bodies[i].r.y))*sqrt((bodies[i++].r.x-bodies[i].r.x)*(bodies[i++].r.x-bodies[i].r.x)+(bodies[i++].r.y-bodies[i].r.y)*(bodies[i++].r.y-bodies[i].r.y))))*(bodies[i++].r-bodies[i].r);`
These are where the types come from

Code:
```typedef struct {
double x;
double y;
} Vector;

typedef struct {
Vector r;
Vector v;
double m;
char name[MAX_NAME];
} Body;```
I'm lost as to what that error is from. Thanks.

2. At the end of your statement:
Code:
`bodies[i++].r-bodies[i].r);`
That needs to be an r.x-bodies or an r.y-bodies (I have no idea which).

3. Thanks! I got it working!

4. I'm a bit concerned that the [i++] expressions are not guaranteed to be computed in the order you expect. I would recommend that you use a "[i+n]" where n is zero to however much you want it to be, and then do
Code:
`i+=max_n;`
after the entire expression.

Also, making it a bit less of a long line would help the understanding of the expression - remember, you or someone else may have to understand the entire expression at some later stage.

Calculating complex expressions as partial components can also help the understanding some.

--
Mats

5. Yuck, what horribly long, wrong, and disgusting code.
Break it down into much smaller parts.