[comp.lang.c] passing arrays to functions

bagchi@sparky.eecs.umich.edu (Ranjan Bagchi) (06/04/90)

    I would like to pass an array to a function, foo(bar *a[]).
Currently, I pass the array by first declaring it...
 
bar *a[] = {bar *a,bar *b,bar *c,bar *d};

...and then passing it to foo(bar *a[]) with foo(a).
 
    What I would like to be able to do is avoid the first step and
just do a ...
 
foo({bar *a,bar *b,bar *c,bar *d});
 
Simply because foo is an initialization routine, and I really have no
use for a (as defined about 10 lines up) elsewhere in the program.
 
Anyway, is there any way to get past the compiler complaints, and
manage to do something in a form like this?
 
    E-mail please, as I don't read this group regularly...
 
    -rj
    bagchi@eecs.umich.edu

rfg@ics.uci.edu (Ronald Guilmette) (06/04/90)

In article <2491@zipeecs.umich.edu> bagchi@sparky.eecs.umich.edu (Ranjan Bagchi) writes:
>
>    I would like to pass an array to a function, foo(bar *a[]).
>Currently, I pass the array by first declaring it...
>
>bar *a[] = {bar *a,bar *b,bar *c,bar *d};
>
>...and then passing it to foo(bar *a[]) with foo(a).
>
>    What I would like to be able to do is avoid the first step and
>just do a ...
>
>foo({bar *a,bar *b,bar *c,bar *d});

The GNU compilers (gcc & g++) allow such an "aggregate constructor" notation.

// Ron Guilmette (rfg@ics.uci.edu)
// C++ Entomologist
// Motto:  If it sticks, force it.  If it breaks, it needed replacing anyway.

dond@clsib21.UUCP (Donald Desjardin) (06/08/90)

To whom it may concern,

    Like "herndon@sctc.com" in article 10937 (comp.sources.wanted), I am
looking for a nice tool to convert 'C' code to a flow diagram.  I have
alot of code to review that has old (un-updated) or no design spec's.

    I have seen LOT'S of these type tools written for PC's but none for
a UNIX system.  I am running on a SEQUENT under BSD.

    Any help would be appreciated!!

    dond%clsib21.uucp



Donald M. Desjardin