Re: Dinamically allocate array of array of structures
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Thu, 31 Aug 2006 18:36:59 GMT
"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.
.
- References:
- Dinamically allocate array of array of structures
- From: valerio
- Dinamically allocate array of array of structures
- Prev by Date: Re: strncpy not that easy to use
- Next by Date: Re: how could I write this cpp macro
- Previous by thread: Re: Dinamically allocate array of array of structures
- Next by thread: Initializing constants
- Index(es):
Relevant Pages
|