Path: utzoo!mnetor!uunet!husc6!yale!cmcl2!brl-adm!adm!GAY%CLSEPF51.BITNET@CUNYVM.CUNY.EDU From: GAY%CLSEPF51.BITNET@CUNYVM.CUNY.EDU Newsgroups: comp.lang.c Subject: Returning several values (was Re: The D programming language) Message-ID: <12206@brl-adm.ARPA> Date: 9 Mar 88 21:18:57 GMT Sender: news@brl-adm.ARPA Lines: 35 To return several values from a function: what's wrong with using struct foo { int a, b; }; struct foo fun(a, b) int a, b; { struct foo temp; temp.a = a / b; temp.b = a % b; return(temp); } I know this isn't as elegant as the proposed method (you have to extract the values from the struct, declare a special purpose structure ...), but it works and exists in at least one implementation of C (Lattice C). I don't know if this is in the ANSI standard, if it isn't it is a fairly logical extension (not needing any new syntax such as the square brackets proposed), and it can even qualify as having prior use ! (I have a vague memory of seeing this feature in other C compilers, but as I've never used many I'm not sure if it is widespread or not (In other words, I hope I'm not saying something that everybody knows ...)). On another subject, the 9876543210L constant, the Lattice C compiler accepts it without flinching. However, such a constant has a real value of 2147483647 (0x7fffffff) (as shown by a printf) which shows that the compiler detected the overflow condition, but didn't signal it ! (Otherwise, the value would have probably been 1286608618 ...). David Gay GAY@CLSEPF51.bitnet I disclaim all responsability for the absence of a disclaimer.