Question of the century? I basically want to know which would be more efficient if I wrote this code as several different variables or if I used small arrays.
int x = 34;
int y = 28;
int z = 293;
vs
double coordinate[3] = {34, 28, 293};
I have a coordinate struct which I will use in the following way:
typedef struct coordinates_t {
double x = 0.0;
double y = 0.0;
double z = 0.0;
} coordinates;
typedef struct car_t {
coordinates start; // car starting point
coordinates location; // car current Location
coordinates targCarVector; // Vector to car from target
coordinates altitude; // Altitude of car
coordinates distance; // Distance from car start to current position
} car;
I'll need to do things like:
distance = car1.location - car1.start;
If I don't use an array I'll have to have a lot of lines of code, but if I use an array I'll have to use loops. Are arrays and loops more memory/cpu intensive? I am basically trying to see which is the most efficient way of writing this code.
Thanks, DemiSheep