Assigning to char[N]

Ali Çehreli acehreli at yahoo.com
Wed Feb 1 14:55:01 PST 2012


import std.stdio;

void main()
{
     char[100] a = "old content";
     a = "new content";
}

The program above causes an exception to be thrown:

object.Exception at src/rt/arraycat.d(31): lengths don't match for array copy

I admit that a fixed-length char array is not really a string. But 
assuming that the new content is legal UTF-8, what is the best way of 
modifying that array?

Thank you,
Ali


More information about the Digitalmars-d-learn mailing list