Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 06, 2004 Bug in split? | ||||
---|---|---|---|---|
| ||||
std.string.split and std.string.splitlines don't seem to be stopping at the delimiters for substrings. Here's an example: char[] str1 = "A B C D"; char[][] str2 = split(str1); Will result with str2 equal to: "A B C D" "B C D" "C D" "D" |
September 06, 2004 Re: Bug in split? | ||||
---|---|---|---|---|
| ||||
Posted in reply to mcl | mcl wrote:
> std.string.split and std.string.splitlines don't seem to be stopping at the
> delimiters for substrings.
>
> Here's an example:
> char[] str1 = "A B C D";
> char[][] str2 = split(str1);
>
> Will result with str2 equal to:
> "A B C D"
> "B C D"
> "C D"
> "D"
This is probably because you're using printf instead of writef. :)
str2's elements point inside str1, but never modifies them, so there is only ever one terminating null.
-- andy
|
September 06, 2004 Re: Bug in split? | ||||
---|---|---|---|---|
| ||||
Posted in reply to mcl | It works for me. Maybe there is something else wrong in your code. Post the entire (but as small as possible) example that has this behaviour. "mcl" <mcl_member@pathlink.com> wrote in message news:chgvft$116p$1@digitaldaemon.com... > std.string.split and std.string.splitlines don't seem to be stopping at the > delimiters for substrings. > > Here's an example: > char[] str1 = "A B C D"; > char[][] str2 = split(str1); > > Will result with str2 equal to: > "A B C D" > "B C D" > "C D" > "D" > > |
September 06, 2004 Re: Bug in split? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | In article <chh0ae$11da$1@digitaldaemon.com>, Andy Friesen says... >This is probably because you're using printf instead of writef. :) > >str2's elements point inside str1, but never modifies them, so there is only ever one terminating null. > > -- andy D'oh! I completely forgot about writef. From now on I'm going to switch over to streams from stdio. But first I need to get some sleep. |
Copyright © 1999-2021 by the D Language Foundation