J
junky_fellow
What is the correct way of dynamically allocating a 2d array ?
I am doing it the following way. Is this correct ?
#include <stdlib.h>
int main(void)
{
int (*arr)(3);
arr = malloc(sizeof(*arr) * 4);
/* I want to dynamically allocate
int arr[4][3] */
arr[2][3] = 100; /* Can I initialize the 3rd column of
2nd row in this manner ? */
}
Thanx in advance for any help ...
I am doing it the following way. Is this correct ?
#include <stdlib.h>
int main(void)
{
int (*arr)(3);
arr = malloc(sizeof(*arr) * 4);
/* I want to dynamically allocate
int arr[4][3] */
arr[2][3] = 100; /* Can I initialize the 3rd column of
2nd row in this manner ? */
}
Thanx in advance for any help ...