home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!ubc-cs!mala.bc.ca!epp
- From: epp@mala.bc.ca (Lorne Epp)
- Newsgroups: comp.lang.c
- Subject: Re: How can I return two value to a procedure ???
- Message-ID: <1992Jul23.065635.590@mala.bc.ca>
- Date: 23 Jul 92 13:56:35 GMT
- References: <9207222041.AA00524@honeydew.cis.ohio-state.edu>
- Organization: Malaspina College
- Lines: 25
-
- In article <9207222041.AA00524@honeydew.cis.ohio-state.edu>, ychung@news.cis.ohio-state.edu (yiu fai chung) writes:
- > I would like to return two values of two variables.
- > How can I do that ?
-
- Just delete your return statement:
-
- > void change_value( int *i, int *j ) /* arguments are pointers to ints */
- > {
- > *i = 2; /* These lines alter the values of the variables */
- > *j = 3; /* that the arguments point to. */
- > return (*i, *j); /* delete this line */
- > }
-
- You would call the function like this:
-
- int a=10,b=11;
-
- change_value( &a, &b ); /* change_value expects pointer-to-int
- arguments, so you pass address-of a
- and b. */
-
- /* Value of a is now 2; b is 3 */
-
- Lorne Epp
- epp@mala.bc.ca
-