Denis Koroskin Wrote: > On Tue, 30 Dec 2008 20:23:07 +0300, Michael P. <[email protected]> wrote: > > > Denis Koroskin Wrote: > > > >> On Tue, 30 Dec 2008 18:56:08 +0300, Michael P. <[email protected]> > >> wrote: > >> > >> > Jarrett Billingsley Wrote: > >> > > >> >> On Mon, Dec 29, 2008 at 10:36 PM, Michael P. <[email protected]> > >> >> wrote: > >> >> > import std.stdio; > >> >> > import std.cstream; > >> >> > void main() > >> >> > { > >> >> > char[][] names; > >> >> > char[] currentName; > >> >> > while( true ) > >> >> > { > >> >> > din.readf( "%s", ¤tName ); > >> >> > 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. > >> > > >> > Under 1.036, this does not work. > >> > > >> > Input: > >> > michael > >> > is > >> > cool > >> > stop > >> > > >> > The output is: > >> > stopeal > >> > st > >> > stop > >> > > >> > What seems to be happening is that the letters of stop are added to > >> the > >> > word, and if the word is longer than stop, then the rest of the > >> letters > >> > of the word are added. > >> > So, I'm not sure if this is a bug or what... > >> > -Michael P. > >> > >> Now, it's not. What you do is overwrite the string again and again. > >> Try putting "currentName = null;" before doing din.readf(). > > > > Thanks, that worked. > > -Michael P. > > Did you understand the difference? Can you explain the behavior (to yourself)?
Not really... I really have no idea why it wouldn't work before.
