如何声明和使用数组2维度



我想这样做:

uint8_t **t;
int i;
int m[100];
int i;
t = calloc(n, sizeof(uint8*));
...
/* m is initialized in other function */
...
for (i=0;i<n;i++)
{
    /* m[i] is calculated here */        
    *t = calloc(1, sizeof(uint8)*m[i]);
}

我想转换此行为

byte [][]t;
int i;
int[] m = new int [100];
...
/* m is initialized in other function */
...
t = new byte[n];
for (i=0;i<n;i++)
{
    /* m[i] is calculated here */
    t[i] = new byte[m[i]]; 
}

这样做正确吗

List是否适合您?然后,您可以根据需要构建一个字节数组,并将其添加到整个List集合对象中?

    List<byte[]> myByteList = new List<byte[]>();
    for (whatever loop )
    {
       byte[] justOne = however you build one byte array;
       myByteList.Add( justOne );
    }

然后您可以稍后对其进行迭代。。。。

foreach( byte[] oneByteArray in myByteList )
{
   do something with the oneByteArray;
}

相关内容

  • 没有找到相关文章

最新更新