How to use strip or stripRight on char[len] ? Thanks.

Adam D. Ruppe destructionator at gmail.com
Thu Feb 22 16:59:40 UTC 2018


On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote:
>  char[100] abc ="aabc    ";
>  auto abcaa = ((abc).dup).stripRight;

try:

auto abcaa = stripRight(abc[])

just make sure you do NOT return that abcaa from the function or 
store it in an object. It still refers to the static array that 
does not outlive that function.

It is simply that these functions require a slice so it can 
resize it and you can't resize a static array.


More information about the Digitalmars-d-learn mailing list