help generating an array of array with malloc or calloc

From: Eric Boutin (eric_at_nic.nac.wdyn.de)
Date: 11/30/03


Date: Sun, 30 Nov 2003 09:06:51 -0500

Hi ! I would like to generate an array of type char[n][5];

I just dont really figure out how I could do it with malloc or calloc.. I
mean.. I know how to allocate a simple array with both of them; but when it
comes to a 2 dimension array.. I'm stuck.. I mean.. if I ask for char**
array = malloc(5*n*sizeof(char));, it'll return a void*, not a void**..
anyone have an idea ?



Relevant Pages

  • Re: efficeincy ( Am I correct ?)
    ... > calloc does the initialisation which is not achived in the malloc ... > to allocate the bytes (no need to initialise it) ... gcc calls a function called bzero to init array to 0. ...
    (comp.lang.c)
  • Re: Casting a generic or void pointer to point to a struct...
    ... that what I really need is known in C as a "dynamic array". ... with malloc() or calloc. ... would use to cast a gneeric or void pointer to a struct that I have ... memory obtained with the calloc() function. ...
    (comp.lang.c)
  • Re: Pointer refering to an array of structutes?
    ... I only have calloc and malloc! ... arr, right? ... makes p point to the first element of this array. ...
    (microsoft.public.vc.language)
  • Re: PHP-like Array/Hash creation in Ruby
    ... but the autogrowing is limited to the last dimension. ... i dont have constant size of elements that could be added in just one ... want to store them in a 3 dimensional array. ... I do like Ruby very much from the first looks ...
    (comp.lang.ruby)
  • Re: Dynamic allocation of a 2 dimensional array
    ... MazeArray is not an array of pointers to pointers. ... malloc or calloc. ...
    (comp.lang.cpp)