Re: Dynamic array of strings and appending a zero length array

2023-07-09 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 8 July 2023 at 20:01:08 UTC, H. S. Teoh wrote: On Sat, Jul 08, 2023 at 05:15:26PM +, Cecil Ward via Digitalmars-d-learn wrote: I have a dynamic array of dstrings and I’m spending dstrings to it. At one point I need to append a zero-length string just to increase the length of t

Re: Dynamic array of strings and appending a zero length array

2023-07-08 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jul 08, 2023 at 05:15:26PM +, Cecil Ward via Digitalmars-d-learn wrote: > I have a dynamic array of dstrings and I’m spending dstrings to it. At > one point I need to append a zero-length string just to increase the > length of the array by one but I can’t have a slot containing garbag

Re: Dynamic array of strings and appending a zero length array

2023-07-08 Thread FeepingCreature via Digitalmars-d-learn
On Saturday, 8 July 2023 at 17:15:26 UTC, Cecil Ward wrote: I have a dynamic array of dstrings and I’m spending dstrings to it. At one point I need to append a zero-length string just to increase the length of the array by one but I can’t have a slot containing garbage. I thought about ++arr.le

Re: Dynamic array of strings and appending a zero length array

2023-07-08 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 8 July 2023 at 17:15:26 UTC, Cecil Ward wrote: I have a dynamic array of dstrings and I’m spending dstrings to it. At one point I need to append a zero-length string just to increase the length of the array by one but I can’t have a slot containing garbage. I thought about ++arr.le

Re: dynamic array of strings

2009-01-01 Thread Gide Nwawudu
On Tue, 30 Dec 2008 10:56:08 -0500, Michael P. wrote: >Jarrett Billingsley Wrote: > >> On Mon, Dec 29, 2008 at 10:36 PM, Michael P. wrote: >> > import std.stdio; >> > import std.cstream; >> > void main() >> > { >> > char[][] names; >> > char[] currentName; >> > while( true ) >> > { >> >d

Re: dynamic array of strings

2008-12-30 Thread Michael P.
>Well, let's go through the code. > > First of all, you should undestand that an array is nothing but a pair of > pointer to first element and its length. > > Since char[] == string in D1, let's use string instead to make code slightly > more readable. > > string[] names; // array of strings t

Re: dynamic array of strings

2008-12-30 Thread Denis Koroskin
On Tue, 30 Dec 2008 20:34:00 +0300, Michael P. wrote: Denis Koroskin Wrote: On Tue, 30 Dec 2008 20:23:07 +0300, Michael P. wrote: > Denis Koroskin Wrote: > >> On Tue, 30 Dec 2008 18:56:08 +0300, Michael P. >> wrote: >> >> > Jarrett Billingsley Wrote: >> > >> >> On Mon, Dec 29, 2008 at

Re: dynamic array of strings

2008-12-30 Thread Michael P.
Denis Koroskin Wrote: > On Tue, 30 Dec 2008 20:23:07 +0300, Michael P. wrote: > > > Denis Koroskin Wrote: > > > >> On Tue, 30 Dec 2008 18:56:08 +0300, Michael P. > >> wrote: > >> > >> > Jarrett Billingsley Wrote: > >> > > >> >> On Mon, Dec 29, 2008 at 10:36 PM, Michael P. > >> >> wrote: > >>

Re: dynamic array of strings

2008-12-30 Thread Denis Koroskin
On Tue, 30 Dec 2008 20:23:07 +0300, Michael P. wrote: Denis Koroskin Wrote: On Tue, 30 Dec 2008 18:56:08 +0300, Michael P. wrote: > Jarrett Billingsley Wrote: > >> On Mon, Dec 29, 2008 at 10:36 PM, Michael P. >> wrote: >> > import std.stdio; >> > import std.cstream; >> > void main() >> >

Re: dynamic array of strings

2008-12-30 Thread Michael P.
Denis Koroskin Wrote: > On Tue, 30 Dec 2008 18:56:08 +0300, Michael P. wrote: > > > Jarrett Billingsley Wrote: > > > >> On Mon, Dec 29, 2008 at 10:36 PM, Michael P. > >> wrote: > >> > import std.stdio; > >> > import std.cstream; > >> > void main() > >> > { > >> > char[][] names; > >> > char

Re: dynamic array of strings

2008-12-30 Thread Denis Koroskin
On Tue, 30 Dec 2008 18:56:08 +0300, Michael P. wrote: Jarrett Billingsley Wrote: On Mon, Dec 29, 2008 at 10:36 PM, Michael P. wrote: > import std.stdio; > import std.cstream; > void main() > { > char[][] names; > char[] currentName; > while( true ) > { >din.readf( "%s", ¤tName ); >

Re: dynamic array of strings

2008-12-30 Thread Michael P.
Jarrett Billingsley Wrote: > On Mon, Dec 29, 2008 at 10:36 PM, Michael P. wrote: > > import std.stdio; > > import std.cstream; > > void main() > > { > > char[][] names; > > char[] currentName; > > while( true ) > > { > >din.readf( "%s", ¤tName ); > >if( currentName == "stop" ) > >

Re: dynamic array of strings

2008-12-29 Thread Tim M
On Tue, 30 Dec 2008 17:00:10 +1300, Jarrett Billingsley wrote: On Mon, Dec 29, 2008 at 10:53 PM, Tim M wrote: Where is din.readf? If it is a c function then it won't be able to set up the dynamic array. In std.cstream, din is an instance of std.stream.Stream bound to standard in.

Re: dynamic array of strings

2008-12-29 Thread Jarrett Billingsley
On Mon, Dec 29, 2008 at 10:53 PM, Tim M wrote: > > Where is din.readf? If it is a c function then it won't be able to set up > the dynamic array. In std.cstream, din is an instance of std.stream.Stream bound to standard in.

Re: dynamic array of strings

2008-12-29 Thread Tim M
On Tue, 30 Dec 2008 16:36:24 +1300, Michael P. wrote: import std.stdio; import std.cstream; void main() { char[][] names; char[] currentName; while( true ) { din.readf( "%s", ¤tName ); if( currentName == "stop" ) { break; } else { //what goes here t

Re: dynamic array of strings

2008-12-29 Thread Jarrett Billingsley
On Mon, Dec 29, 2008 at 10:36 PM, Michael P. 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 ~= cur