Why is the following failing?

ryuukk_ ryuukk.dev at gmail.com
Thu Jan 25 15:20:01 UTC 2024


```D
void main()
{
     char[32] id = 0;
     const(char)* str = "hello";

     id = str[0 .. 6];
}

```


it should be a simple memcpy, why DMD complain?

``onlineapp.d(6): Error: mismatched array lengths 32 and 6 for 
assignment `id[] = str[0..6]```

I'm too tired to notice something obvious?


More information about the Digitalmars-d-learn mailing list