How to pass static array to function not by value?
    Eric via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sat Nov 22 07:45:51 PST 2014
    
    
  
On Saturday, 22 November 2014 at 15:20:55 UTC, drug wrote:
> I tried to pass pointer to static array but it didn't work.
Also, if you really want to be lame and actually use a pointer
try this:
import std.stdio;
void change(int *arr)
{
     arr[1] = 6;
}
void main()
{
     int[3] a = [1, 2, 3];
     writeln("a = ", a);
     change(a.ptr);
     writeln("a = ", a);
}
Maybe this is not so lame because change() can take
any length of static array.
-Eric
    
    
More information about the Digitalmars-d-learn
mailing list