initializing to expressions

Ben Liblit BRL102 at psuvm.psu.edu
Sat Feb 9 06:40:30 AEST 1991


I want to initialize an array with values that are constant, but are in the
form of expressions.  For example,

   double  value[ 2 ] = { sqrt( 2 ) / 2, cos ( sqrt( 5 ) ) };

Is there any way to accomplish this?  I know I could do this in some sort of
'for' loop, or else by assigning values explicitly.  I'd really like to avoid
this, though, as having the initialization in the declaration area would be much
more readable.  The example above is a simplification -- the actual arrays are
quite large and explicit, individual assignment would be too cluttering.

Is there *any* way to convince my compiler (High C Compiler version 2, off of a
Unix box) to give me this sort of initialization within the declaration area?

                            Ben Liblit
                            BRL102 @ psuvm.psu.edu -- BRL102 @ psuvm.bitnet
                            Liblit @ endor.cs.psu.edu
                            "Fais que tes reves soient plus longs que la nuit."



More information about the Comp.lang.c mailing list