Re: Dinamically allocate array of array of structures



"valerio" <valerio.daelli@xxxxxxxxx> writes:
I would like to dinamically allocate an array of array of structures.
To explain this:

struct file{ char* fileName,int inode) myfiles[];
struct file{ char* fileName,int inode) mydirs[][];

but I would like to do it dinamically with linked list.
I am able to do it for myfiles, but not with mydirs.
Pseudo-code is ok.
If this is not so simple I will use static arrays.

Linked lists and arrays are very different things. In a linked list,
each element is allocated separately, and the only way to get to an
element is to traverse all the elements leading up to it. It's a
useful technique if you don't know in advance how many elements you'll
need, but I suspect you really want an array.

The comp.lang.c FAQ is at <http://c-faq.com/>. Question 6.16 is
"How can I dynamically allocate a multidimensional array?". (I highly
recommend reading the rest of the FAQ as well, though perhaps not all
at one sitting.)

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: Questions on Using Python to Teach Data Structures and Algorithms
    ... linked lists produces cache misses rather often, ... arrays do not. ... Small dynamic arrays are faster than linked ...
    (comp.lang.python)
  • Re: C++ vs. .net
    ... > in one of my C++ applications, I have quite a big amount of data ... > (linked lists, arrays, variables, ...) that I'd need to pass to a ...
    (microsoft.public.vc.language)
  • Re: sort a generic linked list?
    ... Arrays are very sortable. ... Well, as pointed out also by Jon Skeet, linked lists can be sorted ... using mergesort in worst-case time O, without extra memory, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: "Dumb Debugginging on the Mainframe"
    ... "Years ago, with procedural languages, we used things like loops, function ... calls, arrays, linked lists, queues and stacks. ...
    (bit.listserv.ibm-main)