D - String
- Don Stewart (4/4) May 20 2002 Sorry if I havn't found this in the docs, but is there an equivalent to ...
- Russ Lewis (17/21) May 21 2002 D uses arrays of chars. Arrays in D may be const-sized or dynamic (most...
- Don Stewart (10/32) May 21 2002 the
Sorry if I havn't found this in the docs, but is there an equivalent to the java String complex type in D ? I see mention of toString in the topics, but cannot see under Types in the documentation, a String class.
May 20 2002
Don Stewart wrote:Sorry if I havn't found this in the docs, but is there an equivalent to the java String complex type in D ? I see mention of toString in the topics, but cannot see under Types in the documentation, a String class.D uses arrays of chars. Arrays in D may be const-sized or dynamic (most string applications would use dynamic arrays, of course). Since the length is known by the length of the array, strings in D are not null-terminated. (there's one caveat: string constants include an unneceesary null terminator-doesn't count towards the length of the array-so that you can pass string constants directly into C functions that expect null terminators.) You can append an array to another with the concatenate operator. Since there are no null terminator, this also works perfectly for strings: char str[] = "asdf"; str ~= "jkl"; /* str now is "asdfjkl" */ http://digitalmars.com/d/arrays.html -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
May 21 2002
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:3CEAB7F7.D58FD38A deming-os.org...Don Stewart wrote:theSorry if I havn't found this in the docs, but is there an equivalent tothejava String complex type in D ? I see mention of toString in the topics, but cannot see under Types instringdocumentation, a String class.D uses arrays of chars. Arrays in D may be const-sized or dynamic (mostapplications would use dynamic arrays, of course). Since the length is known by the length of the array, strings in D are not null-terminated. (there's one caveat: string constants include anunneceesarynull terminator-doesn't count towards the length of the array-so that youcanpass string constants directly into C functions that expect nullterminators.)You can append an array to another with the concatenate operator. Sincethereare no null terminator, this also works perfectly for strings: char str[] = "asdf"; str ~= "jkl"; /* str now is "asdfjkl" */ http://digitalmars.com/d/arrays.html -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]Many Thanks Russ
May 21 2002