用户定义的2d阵列 [英] User Defined 2d Arrays
本文介绍了用户定义的2d阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何将malloc用于二维数组。我有单维数组的代码。
int size;
int *数组;
数组=(int *)malloc(size * sizeof(int));
用户将输入2个变量的数字,因此size1和size2。列的一个量和行的一个量。上面的代码仅适用于其中一个。
I want to know how to malloc for a 2d array. I have the code for a single dimension array.
int size;
int* array;
array = (int*)malloc(size*sizeof(int));
the user will input a number for 2 variables so size1 and size2. One amount for the columns and one for the rows. With the code above its only for one of these.
推荐答案
点击链接 http://www-ee.eng.hawaii.edu/~tep/EE...on2 .1.2.2.html
Follow the link http://www-ee.eng.hawaii.edu/~tep/EE...on2.1.2.2.html
我想知道如何将malloc用于二维数组。我有单维数组的代码。
int size;
int *数组;
数组=(int *)malloc(size * sizeof(int));
用户将输入2个变量的数字,因此size1和size2。列的一个量和行的一个量。上面的代码仅适用于其中一个。
I want to know how to malloc for a 2d array. I have the code for a single dimension array.
int size;
int* array;
array = (int*)malloc(size*sizeof(int));
the user will input a number for 2 variables so size1 and size2. One amount for the columns and one for the rows. With the code above its only for one of these.
我想知道如何为二维数组使用malloc。我有单维数组的代码。
int size;
int *数组;
数组=(int *)malloc(size * sizeof(int));
用户将输入2个变量的数字,因此size1和size2。列的一个量和行的一个量。上面的代码仅适用于其中一个。
I want to know how to malloc for a 2d array. I have the code for a single dimension array.
int size;
int* array;
array = (int*)malloc(size*sizeof(int));
the user will input a number for 2 variables so size1 and size2. One amount for the columns and one for the rows. With the code above its only for one of these.
你可以使用双指针。代码将是,我想(我还没有使用malloc):
You can use a double pointer. The code will be, I think (I haven''t used malloc):
展开 | 选择 | Wrap | 行号
您可以使用双指针。代码将是,我想(我还没有使用malloc):
You can use a double pointer. The code will be, I think (I haven''t used malloc):
展开 | 选择 | Wrap | 行号
这篇关于用户定义的2d阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文