[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

multidimensional arrays

ram

4/25/2011 10:25:00 PM

Here is a programming exercise, I just made up after reading
the other thread named »multidimensional heap arrays«:

Write the following functions (using stdarg.h):

a = aalloc( n, ... )

Allocates an n dimensional int array with the n extensions
given after the first argument, for example, aalloc( 2, 3, 6 )
for a two-dimensional 3x6 array. The type of »a« might be
whatever you need, it does not have to be an array type of
the language C, but also might be a pointer to a struct or so.
It does only need to be accessible by the following other
operations:

int aget( a, ... )

Get the value at the position given by the arguments after
the first argument. (The behavior only needs to be defined
for the case that there are n such arguments, when »a« is
the result of a preceding call to aalloc( n, ... ).)

aset( a, i, ... )

Sets the value at the given position ... to i.

aprint( a, FILE * )

Serialize the array to the file.

aread( a, FILE * )

afree( a )

Release all the resources allocated in a preceding aalloc.