what is the way to dynamically initialize a 2-D array in c
or how could i handle an array of size ar[1000][20000];
plz help me with an example
what is the way to dynamically initialize a 2-D array in c
or how could i handle an array of size ar[1000][20000];
plz help me with an example
i would say it depends on what value you want to initialize your array with.
if it’s 0, you could maybe simply bzero(ar, sizeof(ar))
, right ?
did i properly understand your question ?
Do you know how to use malloc
in general? If so, use it…
char** c2d = (char**)malloc( ... );
for ( int i = 0; i < n; ++i ) {
c2d[i] = (char*)malloc( ... );
}