April 06, 2002 Re: Delegates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Borogove | "Russell Borogove" <kaleja@estarcion.com> wrote in message news:3CAE8210.4020908@estarcion.com... > Ohhh, crap. Well, I lobbied for padding (at least char > and wchar) arrays with an extra zero-valued element to > make conversion to C-strings easier way back when, but > noooooooo.... Literals are terminated with 0 in memory. However, 0 is not considered element of the array: "foo" -> 'f', 'o', 'o', 0 "foo".length == 3; |
April 06, 2002 Re: Delegates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:a8mk4r$n0q$1@digitaldaemon.com... > "Russell Borogove" <kaleja@estarcion.com> wrote in message news:3CAE8210.4020908@estarcion.com... > > > Ohhh, crap. Well, I lobbied for padding (at least char > > and wchar) arrays with an extra zero-valued element to > > make conversion to C-strings easier way back when, but > > noooooooo.... > > Literals are terminated with 0 in memory. However, 0 is not considered element of the array: > > "foo" -> 'f', 'o', 'o', 0 > "foo".length == 3; That's right. It's a bit of a hack, but a hack that works for the most common cases, like passing a string literal to printf! |
April 06, 2002 Re: Delegates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:a8nalt$1fsi$1@digitaldaemon.com... > > Literals are terminated with 0 in memory. However, 0 is not considered element of the array: > > > > "foo" -> 'f', 'o', 'o', 0 > > "foo".length == 3; > > That's right. It's a bit of a hack, but a hack that works for the most common cases, like passing a string literal to printf! It's also great when interfacing with APIs and such. Well, it just works, and variables can always be converted using toStringz(). |
Copyright © 1999-2021 by the D Language Foundation