我开始使用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)
我在网上发现它,在我找到它之前,我曾尝试做同样的事情,但我猜我的语法错了.无论如何,我需要帮助理解旁边有注释的行
c malloc pointers multidimensional-array dynamic-memory-allocation