Date: Sun, 21 Jun 1998 01:59:07 -0500 (CDT) From: Andrew Deren To: "John M. Aldrich" cc: djgpp AT delorie DOT com Subject: Re: how do I pass more than one value out of a function??? In-Reply-To: <358C1A86.CE15E3FB@cs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Sat, 20 Jun 1998, John M. Aldrich wrote: > Sal wrote: > > > > I come from a pascal background... anyway, I know how to use a fundtion to > > ruturn a value. What do I do to mave something that ruturns several > > values?? > > I recommend asking questions like these on comp.lang.c; it's for > C-specific issues, not DJGPP specific ones. > > You return multiple values from a C function in precisely the same way > you do it in Pascal; you pass pointers to the variables you want to > alter as arguments to the function and modify those values. Pascal > refers to this as VAR passing; it has the same effect. You can also > create a struct to hold the values and return that from the function. > Actually I would disagree with that. Pascal var passing is like c++ pass by reference. Passing a pointer is different than passing a reference. TO return several values just use: void foo(int& var1, char& var2, etc...) and then you call the function with the vars as regular function. foo(myInt, myChar); (I agree that this is more for comp.lang.c) > Please read a good C textbook such as _The New C Primer Plus, 2nd > Edition_, by Waite & Del Prata, or Kernighan and Ritchie's _The C > Programming Language, 2nd Edition_. Both are extraordinarily > well-written and will give you all the information you need. > > -- > --------------------------------------------------------------------- > | John M. Aldrich | History has the relation to truth | > | aka Fighteer I | that theology has to religion--i.e., | > | mailto:fighteer AT cs DOT com | none to speak of. | > | http://www.cs.com/fighteer | -Lazarus Long | > --------------------------------------------------------------------- >