Biggest problems w/ D - strings
Jarrett Billingsley
kb3ctd2 at yahoo.com
Mon Aug 13 13:38:01 PDT 2007
"Oskar Linde" <oskar.lindeREM at OVEgmail.com> wrote in message
news:f9qcug$2sgj$1 at digitalmars.com...
> C. Dunn wrote:
>
>> As for your follow-up, I thought that
>> char abc[32];
>> would initialize abc to 32 zeroes automatically. Am I wrong?
>
> chars are initialized to 0xff
There are a few ways to get that initialized to 0 in the struct, tho:
1) Just write the initializer in the struct.
struct S
{
char[32] abc = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
}
Kind of ugly, but straightforward.
2) Typedef a zero-init char type.
typedef char zchar = 0;
struct S
{
zchar[32] abc;
}
You then might run into annoyances when converting between char and zchar.
More information about the Digitalmars-d
mailing list