Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

C++ Arrays Acting Up

Discussion in 'Scripting' started by Faestus, Jul 26, 2014.

  1. Faestus

    Faestus

    Joined:
    Jul 23, 2014
    Posts:
    68
    for example, this array:
    int[][] Numbers={
    (1),
    (2),
    (3),
    (4,5),
    (6)
    };

    I get weird errors at 4,5...

    Can somebody tell me why?
     
  2. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    It's jagged, if you want a two dimensional array, then the other rows should have a second column.
     
  3. Faestus

    Faestus

    Joined:
    Jul 23, 2014
    Posts:
    68
    Nope. This one gives me the same errors.

    int[][] Numbers={
    (1,0),
    (2,0),
    (3,0),
    (4,5),
    (6,0)
    };

    If I use (6|0) it doesn't crash, but does that mean it will chose one of those two?
     
  4. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
  5. Faestus

    Faestus

    Joined:
    Jul 23, 2014
    Posts:
    68
    Ok. It works now.

    But is there a way to get the length of a subint?

    Ie sizeof(Array[0])?

    From what I tried, I got "Array size cannot be specified in a variable declaration" error...