我需要帮助理解这行代码动态创建一个数组?

Chi*_*kem 1 c malloc pointers multidimensional-array dynamic-memory-allocation

我开始使用malloc进行更多练习,尽管它正确执行的代码没有任何问题.

int *arr = (int *)malloc(x * y * sizeof(int));
int i, j, r;

for(i=0; i<x; i++){
    for(j=0; j<y; j++){
        r = 0 + rand() % 7;
        *(arr + i*y + j) = r; 
   //I dont understand the left hand portion of the above line.

//x and y are both 5000
Run Code Online (Sandbox Code Playgroud)

我在网上发现它,在我找到它之前,我曾尝试做同样的事情,但我猜我的语法错了.无论如何,我需要帮助理解旁边有注释的行

Am_*_*ful 6

*(arr + i*y + j)试图将值存储在由表示的数组元素中array[i][j].

从R个接收在先前行什么值,被馈送到阵列[i] [j] 数组的元素.

arr找到数组的基本元素,将i*y定位添加到数组的第(i + 1)行(索引计数从C中的0开始),并将j添加到其中,生成精确列(第j + 1列),其中array[i][j]位于.