2D Arrays (solved)

Started by Scavenger, Wed 15/10/2003 22:00:52

Previous topic - Next topic

Scavenger

I was just wanted to know, how is it again you create 3D arrays like:
character[CHARID].inv

  • Which proves they do exist. Insofar I can only make part of the variable an array, not both. Sorry for the inconveience and n00bish posts, but I searched both the manual and the Tech Forum but I could find nothing on structs, arrays etc. Maybe someone should add it?

    Example:
    struct test {
    short text;
    int whatever; };
    test array;
    Produces:
    array[].text
    array[].whatever

Pumaman

That's not a 3D array, that's just one array inside another (which is in a way, a 2D array).

You can do:

struct Test {
 int elements[10];
};

Test array[10];


then:

array[4].elements[2]   or whatever.

Make sure you don't exceed the array bounds, no checking is done.

Scavenger

Thankye Pumaman! Whatever will we do without you?Most probably perish... or be eaten by some subterrean wildebeest. Long live CJ!

Pumaman

Hehe ;)

For reference, this is not documented in the manual because arrays are not safe (you can declare one with 10 elements, then access element 25, which may crash the game or cause strange random results).

SMF spam blocked by CleanTalk