C ++动态二维数组 [英] C++ dynamic 2D array
本文介绍了C ++动态二维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的代码来创建动态二维数组。
I am using the following code to create dynamic 2D array.
uint32_t** arrays = new uint32_t*[10];
uint32_t number = take input from console ;
arrays[0] = new uint32_t[number];
number = take input from console ;
arrays[1] = new uint32_t[number];
delete arrays[0] ;
number = take input from console ;
arrays[0] = new uint32_t[number] ;
任何人都能帮助我如何知道第二维的大小而不知道输入值?意味着如何在数组[0],数组[1]等上找到数组大小?
Can any one help me how to know the size of the 2nd dimension without knowing the input values ? Means how to find the array size on arrays[0], arrays[1] and so on ?
推荐答案
以确定由 new
分配的内存块的大小,而不存储大小值。
There is no way to determine the size of a memory block allocated by new
without storing the size value.
编辑:不只是使用向量<载体, uint32_t> >数组;
?
这篇关于C ++动态二维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文