Problem with multidimensional array
#1

Edit: sorry, I haved fixed it myself by removing the size of the second dimension:
pawn Код:
new const Float:Bases[][][4]
I have this code:
pawn Код:
new const Float:Bases[][2][4] =
{
    {
        {2489.9683, -1666.2428, 13.3438, 90.0},
        {2301.8442, -1639.3610, 14.6308, 180.0}
    }
};
The first cell of the last dimension should always be X but it isn't working. Am I missing anything?

This code:
pawn Код:
main()
{
    for(new i = 0; i != sizeof(Bases); i++)
    {
        for(new j = 0; j != 2; j++)
        {
            printf("%.4f, %.4f, %.4f, %.4f", Bases[i][j][0], Bases[i][j][1], Bases[i][j][2], Bases[i][j][3]);
        }
    }
}
Prints:
Код:
[11:43:28] 13.3437, 90.0000, 2301.8442, -1639.3609
[11:43:28] 14.6308, 180.0000, 0.0000, 0.0000
I believe that it has to print:
Код:
2489.9683, -1666.2428, 13.3438, 90.0
2301.8442, -1639.3610, 14.6308, 180.0
Reply
#2

If im right you dont need the first dimension youve made there
pawn Код:
new const Float:Bases[2][4] =
{
    {2489.9683, -1666.2428, 13.3438, 90.0},
    {2301.8442, -1639.3610, 14.6308, 180.0}
};

main()
{
    for(new j = 0; j < 2; j++)
    {
        printf("%.4f, %.4f, %.4f, %.4f", Bases[j][0], Bases[j][1], Bases[j][2], Bases[j][3]);
    }
}
Reply
#3

Sorry, I just fixed it myself. You were somehow right but I was going to add more bases so I need three dimensions. Read the first post for the solution.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)