Returning Arrays from Functions
Part of ArraysCategory
Description
Shows how to return arrays from functions.
Example
int[] someFunction() /* dynamic array */ { int[] i; i.length = 5; i[0] = 1; i[1] = 1; i[2] = 2; i[3] = 3; i[4] = 5; return i; } struct fa_int5 /* struct wrapper */ { int[5] i; /* static array */ } fa_int5 someFunction2() { fa_int5 k; k.i[0] = 1; k.i[1] = 1; k.i[2] = 2; k.i[3] = 3; k.i[4] = 5; return k; } void main() { int[] j = someFunction(); fa_int5 m; m = someFunction2(); int[5] n = m.i; }
Source
Link | http://www.dsource.org/tutorials/index.php?show_example=86 |
Posted by | jcc7 |
Date/Time | Sun Jun 27, 2004 10:04 pm |