Two little blog/tutorials posts.
Ivan Senji
ivan.senji_REMOVE_ at _THIS__gmail.com
Tue Feb 28 03:04:05 PST 2006
Jarrett Billingsley wrote:
> "Alan Knowles" <alan at akbhome.com> wrote in message
> news:du0d5a$5j0$1 at digitaldaemon.com...
>
>>I'm sure they are lacking in many ways, but feel free to post
>>comments/corrections ;)
>
>
> Oh, you poor man! Writing code like you're still in C! This is D we're
> talking about here.
>
> int main(char[][] args)
> {
> writefln("Hello World");
> writefln("args.length = ", args.length);
>
> for (int i = 0; i < args.length; i++)
> {
> // Still a good idea to use the %s, so it doesn't escape the arg
> string
> writefln("args[", i, "] = '%s'", args[i]);
> }
>
> return 0;
> }
>
> Or even:
>
> foreach (uint i, char[] arg; args)
> {
> writefln("args[", i, "] = '%s'", arg);
> }
>
Or even:
foreach(i, arg; args)
{
...
}
More information about the Digitalmars-d-learn
mailing list