OK... Im watching this thread now. So I can answer questions.
Ive attached a stand-alone script showing a two-dimensional STRING array in action.
As a point of interest... My PREVIOUS code was INCORRECT... See if you can pick where.
Heres the script...
#include <acknex.h>
#include <default.c>
//
STRING* **myString; //note the TRIPLE-'*' !!!NOT DOUBLE!!! - ask why!
//
int size_x=5, size_y=5; //here are the 'limits' of the array.
//
//
void main()
{
wait(1); draw_textmode("Times",0,24,100); int x,y;
//--------------------------------------------------------------------------------------
//Create and fill the array
myString = (STRING***)malloc(size_x*sizeof(STRING***)); //create the X index
for(x=0; x<size_x; x++)
{ myString[x] = (STRING**)malloc(size_y*sizeof(STRING**)); //create the y index
for(y=0; y<size_y; y++)
{
(myString[x])[y] = str_create("TEST_"); //fill each element of this X index
str_cat_num((myString[x])[y], "%.0fx", x);
str_cat_num((myString[x])[y], "%.0f", y);
}
}
//
// Display the array data as a grid
while(!key_esc)
{
for(x=0; x<size_x; x++) for(y=0; y<size_y; y++)
{ draw_text((myString[x])[y], x*150, y*50, COLOR_WHITE); }
//
wait(1);
}
}
PriNove:: Im not going to answer any of you questions from before this code.
Go over and try this code first. Then ask questions that remain un-answerd
and are not explained by this code...
Rackscha:: Yeah. I know that. But JCL must have put in the 'GS-version' of
malloc() and free() for SOME reason, Im just making guesses as the what they are.
I SUSPECT it is the memory-freeing at engine exit, because before I started
using sys_malloc, I would 'often' get engine crashes on exit if I had been
sloppy and not free'd ALL the memory I had malloc'ed.
The more memory I failed to free, the greater the chance of a crash.
sivan:: Why didnt you point out my mistake? Or did you go straight to using
structs rather than strings? That would have 'skipped' my mistake...
Also as a belated reply...
Its not covered in the manual because
There is plenty information about C, C++, or Windows library functions on the Internet or in online C courses. It is highly recommended for adcanced lite-C programming to work through such a course or book and learn about malloc, memcpy and all the other library functions that you can use.