Dimensionl Arrays Are:: Be Dynamicals Alocated Using A Single
Dimensionl Arrays Are:: Be Dynamicals Alocated Using A Single
CkBde
nt rows = 3, cols = 4;
=
CkBde
rows = 3, cols = 4;
Alócate memory for the rray
int ar= Cint *)mallocrows * cols
sizeofin+),
Assen ualues to the array
int coUnt 3O
for Cinti = O, i< rows, it+)
for int j - O;j< cols, jt+)
*Larr i*cols t ) = +tcount,
Pradt the array
for Linti -= CO,i rowy, it+)
for Lint < cols, jtt)
| *
pintf"n).
cols tti
3
Foee the memory
freelar
- Using an of pointers: A Daray
Can nGso be dunmically allocated wsing
dynhe array
of pointers. he array of
ypointers point to the frt elerment of
each row of the array. lo accesS the
element ati, , we an use a r J
notation, For exaample, to create a U
of size 3 x 4, we can se the
follong code: