Multi-dimensional array using dynamic memory allocation 
Author Message
 Multi-dimensional array using dynamic memory allocation

Hello guys,

I would like to declare a multi-dimensional array using dynamic memory
allocation. While I have the code for one dimension,

int x_length=5;
int *one_dimension_array;
int (int *)malloc(x_length*sizeof(int));
/* test */
one_dimension_array[2]=3453;

I just can't work out how to add the second dimension so I can write
something like

two_dimensions_array[2][3]=3453;

I looked in the previous posts but couldn't find the solution.

Thank you for helping,

regards,
Enrique



Thu, 18 Nov 2004 16:45:35 GMT  
 Multi-dimensional array using dynamic memory allocation
On Sun, 02 Jun 2002 10:45:35 +0200, Enrique Vidal Snchez

Quote:

>Hello guys,

>I would like to declare a multi-dimensional array using dynamic memory

FAQ:
6.16: How can I dynamically allocate a multidimensional array?

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>



Fri, 19 Nov 2004 17:17:44 GMT  
 Multi-dimensional array using dynamic memory allocation
Thank you very much!

regards,
Enrique

Quote:

> On Sun, 02 Jun 2002 10:45:35 +0200, Enrique Vidal Snchez

>>Hello guys,

>>I would like to declare a multi-dimensional array using dynamic memory

> FAQ:
> 6.16: How can I dynamically allocate a multidimensional array?



Thu, 18 Nov 2004 17:30:24 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Multi-dimensional array using dynamic memory allocation

2. Dynamic Memory Allocation For Multi-Dimensional Arrays

3. Dynamic Allocation of Multi-Dimensional Array (Simple Question)

4. Multi-dimensional array memory allocation.

5. Multi-dimensional array memory allocation.

6. Run-time memory allocation for multi-dimensional arrays

7. Dynamic memory allocation of two dimensional arrays

8. Multi-dimensional array allocation - the *easy* way.

9. Dynamic allocation of 2-dimensional array

10. Dynamic allocation and reallocation of two dimensional arrays

11. Dynamic allocation 2 dimensional array

12. Dynamic Allocation of 2-Dimensional Arrays

 

 
Powered by phpBB® Forum Software