multidimensional arrays

Discussion in 'C Programming' started by Stefan Ram, Apr 25, 2011.

  1. Stefan Ram

    Stefan Ram Guest

    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.
    Stefan Ram, Apr 25, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. d[ - - ]b

    Multidimensional arrays? anything else?

    d[ - - ]b, May 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,665
    AlexS
    May 18, 2004
  2. Jay
    Replies:
    1
    Views:
    2,540
    BarryNL
    Jan 30, 2004
  3. geclinke
    Replies:
    1
    Views:
    5,036
    jackie
    Jun 18, 2004
  4. Philipp
    Replies:
    21
    Views:
    1,111
    Philipp
    Jan 20, 2009
  5. Francesco
    Replies:
    2
    Views:
    1,089
    Francesco
    Nov 6, 2009
Loading...

Share This Page