Re: [NEWBIE]Returning an array?

From: George (greerga@CIRCLEMUD.ORG)
Date: 02/21/98


On Sat, 21 Feb 1998, Pure Krome wrote:

>    This is BOG SIMPLE. How do i return an array from a function in some
>file ?

1. Pass the array as a pointer parameter
   - fgets, sprintf, etc
2. Return an 'int *' and treat it like an array.

Problem with #2 is you do not want to rely on another function to free the
memory you have allocated.  And with both of them you will not know how
long the array is unless it is always the same length, but you could
'return' the length with method #1.

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST