I managed to solve my problem ^^
The following source code can take any
char* szArrayOfStuff = { "Cookies", "More Cookies", "Even More Cookies", "No Cookies" }
style sz arrays.
The first function can be fed any char* (szArrayOfStuff + n) individual string and tell you how many characters is in it.
The second function can take the entire char* szArrayOfStuff[] and will tell you the length of the longest character string.
// Takes a single sz and counts along it until it reaches a null
// character, at which point it returns the length of the string from start
// until null.
int getCharStringCurrent(char* szString[])
{
// Initilise the pointer.
char* pszString;
// Set it to the first character of the string.
pszString = *&szString[0];
// Initilise variables used in the loops.
int nNumber = 0;
int nCurrentString = 0;
// I don't like infinite loops that require breaks to end.
bool nComplete = 0;
// While the function isn't complete...
while(nComplete == 0)
{
// If character at pszString+nNumber is not null...
if(*(pszString+nNumber) != '\0')
{
// Increment to look at the next character.
nNumber++;
// And increment the length of the string.
nCurrentString++;
}
// Else if character at pszString + nNumber is null...
else if(*(pszString+nNumber) == '\0')
{
// Function is complete, we can break the while loop.
nComplete = 1;
}
}
// Return the length of the string.
return nCurrentString;
}
// Takes an array of sz and decrements through them counting the number of
// characters in each string. The character size of the largest string within
// the array is returned.
int getCharStringBiggest(char* szString[], int nStrings)
{
// Initilise the pointer.
char* pszString;
// Set it to the first character of the last string.
pszString = *&szString[nStrings-1];
// Initilise variables used in loops.
int nNumber = 0;
int nBiggestString = 0;
int nCurrentString = 0;
// While there are still strings to look at...
while(nStrings != 0)
{
// If the character is null...
if(*(pszString+nNumber) == '\0')
{
// Reset to reading the first character.
nNumber = 0;
// Set new biggest string equal to current string if current is bigger.
if(nCurrentString > nBiggestString)
{
nBiggestString = nCurrentString;
}
// Reset current string.
nCurrentString = 0;
// Decrement the number of strings...
nStrings--;
// And if they are still strings to read, decrement to the next one.
if(nStrings != 0)
{
pszString = *&szString[nStrings-1];
}
}
// Else if the character isn't null...
else if(*(pszString+nNumber) != '\0')
{
// Increment size of current string...
nCurrentString++;
// And increment the character number.
nNumber++;
}
}
// Return the size of the biggest string.
return nBiggestString;
}