Write C code to dynamically allocate one, two and three dimensional arrays (using malloc())

Write C code to dynamically allocate one, two and three dimensional arrays (using malloc())

Its pretty simple to do this in the C language if you know how to use C pointers. Here are some example C code snipptes….

One dimensional array

 

 

 

Two dimensional array

There are more than one methods to allocate two dimensional array dynamically but we use only pointer method. 

 

 

 

Three dimensional array