need help

Regan Heath regan at netwin.co.nz
Mon Apr 24 21:57:12 PDT 2006


On Tue, 25 Apr 2006 11:13:58 +0800, Boris Wang <nano.kago at hotmail.com>  
wrote:
> int main( char[][] args )
> {
>  foreach( char[] arg; args[1 .. args.length] )
>  {
>      printf( "%.*s ", arg );
>  }
>
>  for ( int i = 0; i < args.length; i++ )
>  {
>      printf("%.*s ", args[i] );
>  }
>
>  return 0;
> }
>
> The first printf can't display the information, and the second do.
>
> I use dmd 0.154, XP SP2.

The first one skips the first arg, to include the first arg use:

   foreach( char[] arg; args[0 .. args.length] )
   {
       printf( "%.*s ", arg );
   }

Apart from that they produce identical output for me.

Regan



More information about the Digitalmars-d-learn mailing list