string initialization question.

dcoder dcoder at devnull.com
Fri Jul 30 08:24:41 PDT 2010


Hello.

Is there anyway in D to convenient fill a string variable with a char say X times?

So, I'd like to do something like:

string divider( size, '-');    // C++ notation.
$divider = '-' x $size;        // perl notation.


I thought I could do the following:

const char divider[rowstr.length] = '-';

but the compiler complains about not having a constant integer expression.

thanks.




More information about the Digitalmars-d-learn mailing list