Dup'ing an array onto the stack

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Feb 24 16:42:38 PST 2006

"John Demme" <me at teqdruid.com> wrote in message 
news:dto0oq$tpg$1 at digitaldaemon.com...
>I need to .dup a string on to the stack.  I current have:
> char[] str = ...;
> char[] stackStr = str.dup;
> But it's a lie, since stackStr is stored on the heap.  How do I get it on
> the stack?  I can easily get the space on the stack for it using alloca(),
> but how do I tell the array to use a certain place in memory?

I don't think you can have dynamic arrays point to the stack without some 
ugly hacks.  They're not really meant to point at the stack, as that 
wouldn't work with the dynamic sizing.  Only static arrays can be created on 
the stack.

Why do you need it on the stack? 

More information about the Digitalmars-d-learn mailing list