Well, problem solved.
Here's how to get the length of an array. It's amazing what a PROPER UNDERSTANDING of how functions work will do for you. while() returns a bool. If you keep the last slot in the array as NULL, and NULL values are false. Kinda writes itself really haha.
int getArrayLength(int *array)
{
int n = 0;
while (array[n]) n++;
return n;
}
And here's a block that gets the minimum or maximum value from an array. Requires #define MIN 1 and #define MAX 2 to work as is.
int getArrayLimit(int *array, size_t length, int dir) //set dir to MAX or MIN
{
size_t i = 1; //set idx to 1 as we initialise val to first slot [0]
int *val = array[0];
switch(dir)
{
case 1: for(i; i<length; i++)
{
if((int)val > array[i]) {
val = array[i];
}
} break;
case 2: for(i; i<length; i++)
{
if((int)val < array[i]) {
val = array[i];
}
} break;
default: printf("nSelect MAX or MIN for getArrayLimit()");
}
return val;
}
In all honesty though, getArrayLength was found somewhere here on the forum (in the GS3D area) and getArrayLimit was adapted from a C code block found on SO. Gets the job done though
Cheers,
BobbyT