Mail Archives: djgpp/1998/06/21/02:59:04
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 |
> ---------------------------------------------------------------------
>
- Raw text -