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:38:33 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.

try this:

import std.stdio;

void change(ref int[3] arr)
{
     arr[1] = 6;
}

void main()
{
     int[3] a = [1, 2, 3];

     writeln("a = ", a);
     change(a);
     writeln("a = ", a);

}

-Eric


More information about the Digitalmars-d-learn mailing list