passing structures
Stephen Clamage
steve at taumet.com
Fri Oct 12 01:35:05 AEST 1990
andrew at motto.UUCP (Andrew Walduck) writes:
|In the new ANSI standard, we can now pass (and return) a structure by
|value. Like so...(fragment follows)
|typedef struct complex { int real; int imag; } complex;
|complex add(complex, complex); /* function prototype for complex add */
|Now, here's the problem...what if I wanted to pass a constant structure
|to add! For example I wanted to add 5+8i to a:
|result = add(a,{5,8});
|But this isn't supported by ANSII! There's no way to pass a structure
|as a parameter!
It was never possible to create such an anonymous structure constant in
Classic C, and is still not possible in ANSI C. You can however do
this easily in C++, where such things are fully supported.
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.lang.c
mailing list