dynamic array of strings

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon Dec 29 19:49:50 PST 2008


On Mon, Dec 29, 2008 at 10:36 PM, Michael P. <baseball.mjp at gmail.com> wrote:
> import std.stdio;
> import std.cstream;
> void main()
> {
>  char[][] names;
>  char[] currentName;
>  while( true )
>  {
>    din.readf( "%s", &currentName );
>    if( currentName == "stop" )
>    {
>      break;
>    }
>    else
>    {
names ~= currentName;
>    }
>  }
>  foreach( name; names )
>  {
>    writefln( name );
>  }
> }

~= performs an append.  It adds the given item to the end of the array.


More information about the Digitalmars-d-learn mailing list