1. tripd and array

Hi,
So I am a very novice programmer, and have never tried to do this before.

I need a tripd define the x,y and z components of a vector.
Code:
```vij2.fx = ri[0].fx - pos2.fx;
vij2.fy = ri[0].fy - pos2.fy;
vij2.fz = ri[0].fz - pos2.fz;

vij3.fx = ri[0].fx - pos3.fx;
vij3.fy = ri[0].fy - pos3.fy;
vij3.fz = ri[0].fz - pos3.fz;

vij4.fx = ri[0].fx - pos4.fx;
vij4.fy = ri[0].fy - pos4.fy;
vij4.fz = ri[0].fz - pos4.fz;```
I have everything declared as a tripd, but it seems like it would be infinitly more efficient to do a tripd/array combo.

Code:
```for (k = 2; k < 5; k++)
{
vij[k].fx = ri[0].fx - pos[k].fx;
vij[k].fy = ri[0].fy - pos[k].fy;
vij[k].fz = ri[0].fz - pos[k].fz;
}```
The question is can I do this, I thought it would be easier to ask here rather than deal with a five page compiler error in Unix.
Thanks
Rachael

2. The former is far more efficient, just more work.
Everything is right there, where as in your loop, there are conditional branches and addition to find what spot in memory to place each result.

3. >> infinitly more efficient

4. The former is far more efficient
Not necessarily. Incrementing a counter variable may be faster than incrementing internal instruction pointers. The processor can cache the instructions, and execute the loop directly without needing to fetch code from memory. The looping program will also consume less disk space, and use less memory at runtime. Thus it will start up faster.

Yes, unfortunately, C is rather close to the machine, don't you think?