【发布时间】:2016-02-17 04:11:27
【问题描述】:
我开始对 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
我在网上找到了它,在找到它之前,我曾尝试做完全相同的事情,但我猜我的语法是错误的。无论如何,我需要帮助理解旁边有评论的那一行
【问题讨论】:
标签: c pointers multidimensional-array malloc dynamic-memory-allocation