January 23, 2003
is it just me or does this look a bit funny...

{
char[][] result = split("garry,barry,harry", ",");

for(int i = 0; i < result.length; i++)
printf("%s\n", (char*)result[i]);
}

prints:
garry,barry,harry
barry,harry
harry

personally, i was expecting
garry
barry
harry


March 06, 2003
"Paul Stanton" <Paul_member@pathlink.com> wrote in message news:b0por5$5dc$1@digitaldaemon.com...
> is it just me or does this look a bit funny...
>
> {
> char[][] result = split("garry,barry,harry", ",");
>
> for(int i = 0; i < result.length; i++)
> printf("%s\n", (char*)result[i]);
> }
>
> prints:
> garry,barry,harry
> barry,harry
> harry
>
> personally, i was expecting
> garry
> barry
> harry

This is happening because %s is expecting a null terminated string. char[] in D are not null terminated. Try using %.*s instead, and you should get the answer you expect.