Skip to content

Reset 2D array #746

@vawylon

Description

@vawylon

Greetings, dear friends!

We think it's necessary to add a warning or error about assigning two-dimensional arrays in the compiler. This will be helpful for beginners. Thank you!

#include <open.mp>

new Array[10][30][5];
new const resetArray[30][5] = {{0, ...}, ...};

main()
{
    for(new i; i<10; i++) {
        Array[i] = resetArray;
    }
    for(new a; a<10; a++) {
        for(new b; b<30; b++) {
            for(new c; c<5; c++) {
                printf("Array[%d][%d][%d] = %d", a, b, c, Array[a][b][c]);
            }
        }
    }
}
[08:14:08] [Info] Array[0][0][0] = 120
[08:14:08] [Info] Array[0][0][1] = 136
[08:14:08] [Info] Array[0][0][2] = 152
[08:14:08] [Info] Array[0][0][3] = 168
[08:14:08] [Info] Array[0][0][4] = 184
[08:14:08] [Info] Array[0][1][0] = 200
[08:14:08] [Info] Array[0][1][1] = 216
[08:14:08] [Info] Array[0][1][2] = 232
[08:14:08] [Info] Array[0][1][3] = 248
[08:14:08] [Info] Array[0][1][4] = 264
[08:14:08] [Info] Array[0][2][0] = 280
[08:14:08] [Info] Array[0][2][1] = 296
[08:14:08] [Info] Array[0][2][2] = 312

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions